Scripting objects in SSMS (2008)

  • 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

  • Did you try with the following menu

    "Script Stored Procedure as" --> "Alter To" --> "New Query Editor Window"

  • 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

  • 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.

  • 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.

  • 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.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply