transactional replication and udfs

  • Hi,

    is there an issue using udfs in transactional replication? I am getting an error when trying to replicate a table with the following schema.

    =========================================

    CREATE TABLE [dbo].[PolicyDocument](

    [PolicyDocumentId] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,

    [PolicyVersionId] [int] NOT NULL,

    [DocumentMimeType] [varchar](100) NOT NULL,

    [DocumentType] [varchar](100) NOT NULL,

    [DocumentFileName] [varchar](100) NOT NULL,

    [DocumentBinary] [varbinary](max) NOT NULL,

    [VersionDate] [datetime] NOT NULL,

    [PolicyId] AS ([dbo].[fn_policyid_from_policyversionid]([PolicyVersionId])),

    CONSTRAINT [pk_policy_document] PRIMARY KEY CLUSTERED

    (

    [PolicyDocumentId] ASC

    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

    ) ON [PRIMARY]

    GO

    SET ANSI_PADDING OFF

    GO

    ALTER TABLE [dbo].[PolicyDocument] WITH CHECK ADD CONSTRAINT [fk_policy_document_policy_version] FOREIGN KEY([PolicyVersionId])

    REFERENCES [dbo].[PolicyVersion] ([PolicyVersionId])

    GO

    ALTER TABLE [dbo].[PolicyDocument] CHECK CONSTRAINT [fk_policy_document_policy_version]

    GO

    ALTER TABLE [dbo].[PolicyDocument] ADD DEFAULT (getdate()) FOR [VersionDate]

    GO

    =============================================

    The error is

    Cannot find either column "dbo" or the user-defined function or aggregate "dbo.fn_policyid_from_policyversionid" or the name is ambigious"

  • Does the function exist in the subscriber database?

    If not, create it there and try again.

  • yes that almost worked.

    I created the function on the subscriber then I got a new error about not being able to drop the PolicyDocument table. The issue was that the function had schemabinding property on it so I recreated it without the schemabinding property - all good!

    Thanks!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply