Settings and activity
2 results found
-
47 votes
An error occurred while saving the comment An error occurred while saving the comment SqlNightOwl commentedTreating DRI foreign key constraints as seperate objects will permit tables to be created in any order and then have the foreign keys applied.
SqlNightOwl supported this idea · -
27 votes
For now, you may be able to use a batch file that executes SQL and drops the objects you want re-created before using the SQL Compare Command Line API. Since the objects are dropped, the synch script will generate CREATE scripts instead of alter.
If you wanted to create everything from scratch, you could drop and recreate the database, which would generate all CREATE scripts.
I hope this helps for now.
An error occurred while saving the comment SqlNightOwl commentedI'd change from a drop to a create if not exitsts and then save all scripts as ALTER OBJECT
such as:
if object_id(N'schema.procedurename', N'P') is null
exec sys.sp_executesql 'create schema.procedurename as select 1 as stub';
go
alter procedure schema.procedurenameetc.
etc.
...Keeping to an ALTER scenario will leave any security settings in place.
ALSO: keep/add the GO batch seperator as part of the script.
SqlNightOwl supported this idea ·
I'm more concerned about foreign keys than indexes. Foreign keys imply a build sequence that must be followed. If FK's are in a seperate script then they can be applied last.