开发者

Where is stored the 'NOT FOR REPLICATION' BIT

开发者 https://www.devze.com 2023-03-21 07:47 出处:网络
I am scripting out the foreign keys for a SQL Server database, and so far I have been able to find all the pertinent information to add a foreign key to the table.

I am scripting out the foreign keys for a SQL Server database, and so far I have been able to find all the pertinent information to add a foreign key to the table. The only piece of code that is missing is开发者_开发百科 the 'NOT FOR REPLICATION' (see below) Does anyone know where does this piece of information live?

ALTER TABLE [dbo].[Accountxxxx]  WITH NOCHECK ADD
    CONSTRAINT [FK_Accountxxxx_Accountxxxx_zzzz] 
FOREIGN KEY([D_XX_Guid])
REFERENCES [dbo].[second_table_name] ([Guid])
NOT FOR REPLICATION 

Thanks, E.


sys.foreign_keys contains that information in a fairly straightforward fashion:

is_not_for_replication    bit    FOREIGN KEY constraint was created by using the NOT FOR REPLICATION option.

If that's not what you're after, perhaps you can elaborate on how you're doing your scripting (SSMS should be scripting this option as appropriate).

0

精彩评论

暂无评论...
验证码 换一张
取 消