Tuesday, 15 February 2011

sql server - ms sql smo:how to script foreign key WITHOUT "Alter table MyTable check constraint MyForeignKey" -



sql server - ms sql smo:how to script foreign key WITHOUT "Alter table MyTable check constraint MyForeignKey" -

i see server 2008 generated script:

alter table [mytable] check add together constraint [fk_mytable_id] foreign key([id]) references [mytable2] ([id]) on update cascade on delete cascade go alter table mytable check constraint [fk_mytable_id]

last statement redundant, script works fine without it. generate scripts of foreign keys using smo , want avoid lastly string. can it?

the check constraint section ensures constraint enabled. shouldn't necessary should enabled initial statement.

this question looks similar on stackoverflow: t-sql foreign key check constraint

sql-server foreign-keys smo

No comments:

Post a Comment