How to copy a table including all constraints,... to same database

How to copy a table including all constraints,... to same database

Post by Umlja » Thu, 16 Mar 2006 05:23:27


Hello,

Is it possible to copy a table to a new table in the same database? to
include all constraints, keys, triggers? I noticed in the dropdown menu in
Enterpirse Manager when I right-click on a table there is a Copy selection
but no paste selection. I appologize in advance if I sound amateur here. Is
there an sp I can run in Query Analyzer? How can I accomplish this?

Thanks,
Rich
 
 
 

How to copy a table including all constraints,... to same database

Post by Umlja » Thu, 16 Mar 2006 05:38:27

After giving this some consideration, I will guess that there is not a way to
copy a table with all the guts like keys, constraints, triggers because I
guess those things are all unique. Any comments appreciated in case I am
wrong here.

 
 
 

How to copy a table including all constraints,... to same database

Post by JT » Fri, 17 Mar 2006 00:08:39

You can use DTS (SQL Server 2000) or SSIS (SQL Server 2005) to copy a table
and all it's keys, constraints, triggers, etc. The problem with copying a
table to the same database is that the object names must be unique. If you
are wanting to copy data for offline testing or reporting purposes, then it
would be best to copy to seperate database designated for that purpose.