SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Scripting objects in SSMS (2008)


Scripting objects in SSMS (2008)

Author
Message
Adam Bean
Adam Bean
SSCrazy
SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)

Group: General Forum Members
Points: 2482 Visits: 2192
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.
Shinny-310630
Shinny-310630
SSC-Enthusiastic
SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)

Group: General Forum Members
Points: 184 Visits: 191
Did you try with the following menu
"Script Stored Procedure as" --> "Alter To" --> "New Query Editor Window"
Adam Bean
Adam Bean
SSCrazy
SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)

Group: General Forum Members
Points: 2482 Visits: 2192
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.
Shinny-310630
Shinny-310630
SSC-Enthusiastic
SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)

Group: General Forum Members
Points: 184 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.
winash
winash
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1774 Visits: 1883
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.



Adam Bean
Adam Bean
SSCrazy
SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)

Group: General Forum Members
Points: 2482 Visits: 2192
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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search