SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 copy data from one table to another with constrain
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

amurark
Yak Posting Veteran

India
53 Posts

Posted - 12/26/2012 :  10:10:02  Show Profile  Reply with Quote
hi all
Pls tell me how to copy one table from another with its constrints structure

I tried
Select * into table2 from table1

but it don't copy constraints , indexes, triggers etc.

Pls tell me how to do it

Ankita

jimf
Flowing Fount of Yak Knowledge

USA
2869 Posts

Posted - 12/26/2012 :  11:37:40  Show Profile  Reply with Quote
You can't do that, SELECT INTO only copies structure and data types. To get everything, it'd be better to create the table first, anyway. You can go in to Object Explorer, right-click on table1, then choose SCRIPT TABLE AS ---> Create.
Then just change then name to table2 before you run the script. You may need to go in to tools\options\ SQL Server Object Explorer\ Scripting to make sure that all the objects you want get scripted.

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 12/26/2012 :  23:03:16  Show Profile  Reply with Quote
quote:
Originally posted by amurark

hi all
Pls tell me how to copy one table from another with its constrints structure

I tried
Select * into table2 from table1

but it don't copy constraints , indexes, triggers etc.

Pls tell me how to do it

Ankita



generate scripts using wizard accessed from tasks-> generate scripts and you can select what all properties you want to script out.


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000