How to change how SSMS Scripting generates code

  • Currently when I use SSMS 2005 to generate a CREATE script of an existing object by right-clicking the Object and selecting :

    Script OBJECT As--->CREATE To

    the resulting Query Window has a CREATE Object statement that uses the sp_executesql @statement SP where @statement is the complete T-SQL for creating the object. I want to get the script to not use the sp_ExecuteSQL SP but provide just the CREATE OBJECT T-SQL.

    Is there anyway like a Scripting option in SSMS to get it to not use the sp_ExecuteSQL SP in the script it generates? I swear it use to generate scripts without using sp_ExecuteSQL and I don't know when this changed I just know I'd like to revert it back to the way it used to work.

    NOTE: I have recently installed SQL Server 2008 (Tools & DB Engine) and kept my SQL 2005 DB Engine & Tools so I'm not sure if installing 2008 perhaps made some change that affected 2005 tools.

    Thanks

    Kindest Regards,

    Just say No to Facebook!
  • Typically, the Scripter has to use Dynamic SQL like this when the "Include IF NOT EXISTS" option is set.

    Turn that off and you should see hardly any dynamic SQL in your scripts.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Setting Include IF NOT EXISTS clause to False did the trick.

    Thanks!

    Kindest Regards,

    Just say No to Facebook!
  • Glad I could help!

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

Viewing 4 posts - 1 through 3 (of 3 total)

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