script if exists drop then create

  • in sql server 2012 i created an index then was going to create the script to do the if existence check then drop index and create it. In 2012 if doesn't appear to include the if eixsts part. just drop and create.

    Im right clicking the index then script index as then drop and create.

    in 2008r2 the existece check was automatically coded in. Is there a setting somewhere in sql server 2012 where i can for the wxistence check to be scripted?

  • Snargables (12/14/2012)


    in sql server 2012 i created an index then was going to create the script to do the if existence check then drop index and create it. In 2012 if doesn't appear to include the if eixsts part. just drop and create.

    Im right clicking the index then script index as then drop and create.

    in 2008r2 the existece check was automatically coded in. Is there a setting somewhere in sql server 2012 where i can for the wxistence check to be scripted?

    Apparently in 2012, the default is to have this off. You can turn the check for existence back on in SSMS by going to:

    Tools -> Options -> SQL Server Object Explorer -> Scripting -> Check for object existence -> True

    HTH,

    Rob

  • excellent. thank u

  • The only difference however between 2008 and 2012 is 2012 will produce the query in dynamic sql. Why Microsoft?!

    Anyhow, I typically just delete the the dynamic markup, do a find and replace on all double single qoutes ('') and delete the last quote and END keyword and it's done.

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

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