August 14, 2008 at 1:35 pm
I cannot seem to be able to generate the "IF EXISTS" portion of the DROP statement for Stored Procedures when using the scripting tool from the right click menu In Management Studio from the database tree under Tasks-> Generate Scripts for all stored procedures in the database. Anyone else noticed this issue? I am trying to set up baseline files for all my stored procedures in Visual Source Save and I need the DROP statements in each script file to be conditional.
Regards,
CVM
August 14, 2008 at 1:55 pm
In Management Studio, go to Tools, Options, Scripting. There's an option there to include drop statements in scripts.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
August 14, 2008 at 2:13 pm
Yes, thanks, but it doesn't generate the IF EXISTS part of the drop statement...
August 14, 2008 at 3:20 pm
Sorry, misread your post the first time.
No, I don't believe there is an option for that. Not in Management Studio anyway. Might be something in one of the RedGate or ApexSQL tools, or some such.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
August 14, 2008 at 3:40 pm
If you right click on a single stored proc and script out a drop statement for it, the IF EXISTS is generated as part of the DROP. This has always been the case in all prior versions of SQL Server scripting tools. I'm just wondering where this feature went for 2005 and 2008 as well... If I use IF NOT EXISTS this option generates the IF EXISTS
August 14, 2008 at 3:43 pm
If you right click on a single stored proc and script out a drop statement for it, the IF EXISTS is generated as part of the DROP. This has always been the case in all prior versions of SQL Server scripting tools. I'm just wondering where this feature went for 2005 and 2008 as well... If I use IF NOT EXISTS this option generates the IF EXISTS code for the DROP statement (which is what I'm looking for) however it puts the whole CREATE statement inside an EXEC dbo.sp_executesql clause, which I don't want.
Regards,
CVM
February 9, 2010 at 2:40 pm
GSquared,
Do you know to enable Tools-Options...-Scripting in the Management Studio Menu. Because I do not see the scripting menu in there.
Thanks
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply