Comments
2 comments
-
It's the object existence check that is forcing SQL Compare to use sp_executesql. CREATE/ALTER PROCEDURE has to be the first statement in a block, so it can't follow a conditional. If you try it in SSMS, you'll get a syntax error.
If you turn off the 'Add object existence checks' option, you'll get the straight CREATE/ALTER behaviour back. -
An option to generate existential DROP, then always CREATE would be nice. It allows scripting of "new" stuff to get rid of the old, and has the CREATE body in real SQL rather than in an executed string.
Add comment
Please sign in to leave a comment.
Have used earlier version SQL Compare in the past, and know that it generated Create/Alter proc statements in "native" format - straight Create and Alter commands.
Testing V11 is generating these commands within "red code", using sp_executesql.
i.e.
IF OBJECT_ID(N'[Archive].[MYProc]', 'P') IS NOT NULL
EXEC sp_executesql N'
ALTER Procedure [Archive].[MYProc] . . . .
END
'
Would like to have the script default to
IF OBJECT_ID(N'[Archive].[MYProc]', 'P') IS NOT NULL
ALTER Procedure [Archive].[MYProc] . . . .
END
Don't see an option to make this happen. AM I missing it?
Thanks