Script all tables contraints, indexes, keys and triggers

  • Hi all,

    Is there a way to script all tables contraints, indexes, keys and triggers for a database?

    Thanks.

  • Hi,

    In Management Studio, right-Click on the database in object explorer, choose Tasks -> Generate Scripts...

    You can then select which objects you want to script, whether or not to script the data, and scripting options.

    Hope that helps.

    Gaz

  • yes, SSMS provides a built in GUI functionality to do that; it's highly configurable via checkboxes to determine what to script or not.

    simply right click on the database and follow the wizard from there.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Are you looking to write a query instead of the management studio right click version?

  • I have too many tables. If I use "generate script" then it will create the table creation script as well. I don't want to create the scripts for creating the tables. Only want to create one script for contraints, keys, triggers and indexes for all tables for a given database.

    Thanks.

  • ramadesai108 (3/21/2012)


    I have too many tables. If I use "generate script" then it will create the table creation script as well. I don't want to create the scripts for creating the tables. Only want to create one script for contraints, keys, triggers and indexes for all tables for a given database.

    Thanks.

    in that case, you probably just want to search the submitted scripts here on SSC for each kind of items you want to script.."Script All Indexes", "Script Foreign Keys", etc, and put together a script from those sources that gets all teh data you are looking for.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

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

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