March 21, 2012 at 7:31 am
Hi all,
Is there a way to script all tables contraints, indexes, keys and triggers for a database?
Thanks.
March 21, 2012 at 7:39 am
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
March 21, 2012 at 7:47 am
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
March 21, 2012 at 7:48 am
Are you looking to write a query instead of the management studio right click version?
March 21, 2012 at 7:59 am
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.
March 21, 2012 at 8:05 am
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
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply