SQL Server Performance

Issue with Generating Scripts in SQL 2008

Discussion in 'SQL Server 2008 General Developer Questions' started by apat, Sep 13, 2010.

  1. apat New Member

    Hello Experts,

    I am using the feature in sql server 2008 to generate scripts for all the tables within a database. I see an option "If not exists --> create table" for create table script.

    Is there an option where I can add,

    If exists --> drop table --> create table for auto generate scripts for all the user tables within a database?

    I need this because I get scripts on regular basis which create tables and table definition may change so I have to drop them first and then create all over again. I tried using "drop script" but it doesnt work. I need If exists --> drop -- Create table...

    Thanks in advance...
  2. Luis Martin Moderator

    May be I'm wrong, but I think you have that option table by table and no for all tables,
  3. ashish287 New Member

    try to select the option " select drop" in "choose script options".
    It will not be like if exists then drop but it will have syntax like drop table before creation of the table(in short kind of same thing).
    No Luis, in 2008, if tyou right click on the database and you will see the option to create script and then you can script either all objects or filter it further to specific object.
  4. satya Moderator

    You may try from SSMS in Tools > Options > Designers > Table and Database Designers there's an option for 'Auto generate change scripts' that will generate one for every change you make at the time you save it.
    If you want to a Microsoft solution you can try: Microsoft SQL Server Database Publishing Wizard 1.1

    http://www.microsoft.com/downloads/details.aspx?FamilyId=56E5B1C5-BF17-42E0-A410-371A838E570A&displaylang=en

    If you need you can look at third party tools such as APEX SQL Script which works
    good.

Share This Page