July 29, 2010 at 7:42 am
Database = sql server 2005 express edition
i want to copy Existing table structure of one table to another Existing table.
why i want to do it?
i made a software and almost 50 clients are using that software
my clients started working on that software and input huge data in it.
now i was working to improve my software and i added some new constraints, triggers, keys, indexes , procedures , views and functions in my database.
Now function , views and procedures were easy to script and i did that using sql create script method and ran that script on my client's database.
but i don't know how to copy triggers, constraints, primary keys and indexes.
i cant use select * into method as i have used identity columns in my database and if i use select * into it will create new ids for my table and the links to other tables will be destroyed.
and doing it manually is hell of a job soooooo can any one pls tell me how to either copy whole structure of a table or to copy triggers, indexes etc
July 29, 2010 at 9:56 am
in SQL Server Management Studio, have you tried right clicking on the table and selecting "Script Table As ..."
Then you can rename the table and the constraints that are part of the definition(so they are unique again).
let us know if that works for you.
Lowell
July 30, 2010 at 2:55 am
thanks for the reply
yes i have checked it and it adds constraints but no triggers or indexes.
and this is a create method i cant create a new table and rename it
cause if i do so how am i going to copy customers data in new table and if i use insert tsql to insert data the identity column's data will be change as it will start identity all over again which links to other child tables.
i know alter changes column name or data types but i dnt know how to add triggers or indexes.
i have attached a screen shot of a database diagram just to make it easier kindly check it
July 30, 2010 at 7:36 am
go to the scripting options and check "script indexes" "script "triggers" and anything else you might need scripted,a nds simply rerun the process.
Lowell
July 30, 2010 at 11:44 pm
wow 🙂 that worked well
thanks for the help bro
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply