Olaf Doschke
Programmer
I have a table with a foreign key (uniqueidentifier, doesn't matter) and the corresponding referential integrity constraints to always refer to a record in the foreign table, of course not nullable.
The need for that reference is not there anymore, but I don't want to drop the field. In the future it can be set NULL, but I want to keep current references as historical data.
If I use SQL Server Management Studio and manually change the field to be NULL, then generate an sql script the script is huge and actually drops all constraints, recreates a temp table, copies all data to it, etc. to finally drop the old table and rename the new one.
Is there another, simpler chance to make this via a script?
I need a script, because doing it manually on the development server does not help, I either need to do this manually in the productive server too at the time the new application version is rolled out, or - what I usually rather do, I execute an sql script to change the database.
I can see the need to drop the single constraint regarding that one foreign key, but I think this should result in a shorter script than 205 lines, to make a foreign key field nullable and drop it's contraint.
How would you go about this?
Bye, Olaf.
The need for that reference is not there anymore, but I don't want to drop the field. In the future it can be set NULL, but I want to keep current references as historical data.
If I use SQL Server Management Studio and manually change the field to be NULL, then generate an sql script the script is huge and actually drops all constraints, recreates a temp table, copies all data to it, etc. to finally drop the old table and rename the new one.
Is there another, simpler chance to make this via a script?
I need a script, because doing it manually on the development server does not help, I either need to do this manually in the productive server too at the time the new application version is rolled out, or - what I usually rather do, I execute an sql script to change the database.
I can see the need to drop the single constraint regarding that one foreign key, but I think this should result in a shorter script than 205 lines, to make a foreign key field nullable and drop it's contraint.
How would you go about this?
Bye, Olaf.