Short situation sketch (I have a many databases who all have the same table, but who can have different Indexes or Triggers or ...) I'm trying to create a program that can make an exact copy of a table (including indexes, triggers and other constraints). A part of the data should also be copied to the new database. I already know that you can do this through the SSMS option Generate and Publish Scripts, but this is great for if you have to do this one or two times. But I'm faced with much more databases. So I'm looking for a way to do this in code (or script). Does anyone have an idea?
Asked
Active
Viewed 1,229 times
0
-
http://stackoverflow.com/questions/10201661/copy-access-table-structure-and-constraints-using-c-sharp-or-sql – Sasidharan Aug 26 '13 at 08:44
2 Answers
1
If you dont want to use the tools within SSMS, or any other third-party tool to generate your scripts, then you may have to do what they do - use the meta-data stored in Sql Server regarding the table, columns, indexes (stored in the different INFORMATION_SCHEMA views) to retrieve the info that you need, and then use it to build the scripts that you need.
You can see an example of that with this answer.

Community
- 1
- 1

Yaakov Ellis
- 40,752
- 27
- 129
- 174