Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Scripting objects in SSMS (2008) Expand / Collapse
Author
Message
Posted Monday, December 08, 2008 2:18 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, April 14, 2014 9:45 AM
Points: 1,145, Visits: 1,922
Hey all,

I've been running 2008 SSMS locally for quite some time now ... and I think it was post CU2 install that I started having this problem. Anytime I right click a procedure and choose modify and/or script to create/drop/alter, it's wrapping the object in dynamic SQL!?

For example, right click "BackupDB" (procedure) -> modify =
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[BackUpDB]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'ALTER PROCEDURE [dbo].[BackUpDB]

Do the same in 2005 SSMS ...
ALTER PROCEDURE [dbo].[BackUpDB] 

I tried removing the "Include IF NOT EXISTS clause" under scripting options and it did not change.

Thoughts, comments, suggestions?

Thanks


---
SQLSlayer
Making SQL do what we want it to do.

Post #615786
Posted Monday, December 08, 2008 2:41 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, January 06, 2011 10:38 AM
Points: 182, Visits: 191
Did you try with the following menu
"Script Stored Procedure as" --> "Alter To" --> "New Query Editor Window"
Post #615806
Posted Monday, December 08, 2008 2:47 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, April 14, 2014 9:45 AM
Points: 1,145, Visits: 1,922
Shinny (12/8/2008)
Did you try with the following menu
"Script Stored Procedure as" --> "Alter To" --> "New Query Editor Window"


Yes, as stated all variations ... create / alter / drop, all return the same. Again, not happening in 2005 SSMS and I'm 99% positive I didn't have this problem while running on CU1 for the first couple months in 2008. I definitely think this is a CU2 issue, but not sure if it's intended and/or if it can be turned off.

Thanks


---
SQLSlayer
Making SQL do what we want it to do.

Post #615807
Posted Monday, December 08, 2008 3:00 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, January 06, 2011 10:38 AM
Points: 182, Visits: 191
Are you sure

Object scripting options --> Include IF NOT EXISTS Clause is False.

I changed this to True then the Modify option used dynamic SQL, If it is false, uses SQL.
Post #615813
Posted Monday, December 08, 2008 3:14 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, February 18, 2013 3:46 AM
Points: 1,422, Visits: 1,883
I'm not able to repro it in my CU2 environment (that's version 10.0.1763.0 right?)

Like Shinny mentioned - if the "Include IF NOT Exists Clause" is set to True then I get dynamic SQL else normal 2005-esque stuff.




Post #615820
Posted Tuesday, December 09, 2008 12:30 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, April 14, 2014 9:45 AM
Points: 1,145, Visits: 1,922
Crazyness, I know everyone is going to scream user error ... but toggling that on and off yesterday had no effect. Came in today, restarted my computer for other issues and now it's working just fine. I can even toggle it back to TRUE and it does in fact add the lame dynamic SQL IF EXISTS garbage ... Which honestly, how lazy is Microsoft?

Anyways, all is well.

Thanks for the help.


---
SQLSlayer
Making SQL do what we want it to do.

Post #616421
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse