Copy table with key and idenfier

accessman2

Registered User.
Local time
Today, 02:16
Joined
Sep 15, 2005
Messages
335
Hi,

do we have a T-SQL command to copy table with key and identifier and deflaut value?
because I use select * into dbo.newtbl from dbo.oldtbl, it doesn't copy key and identifier and deflaut values.
 
Hi there

Bu design select into does not copy constraints, largely because it doesn't know what constraints to keep.

Either create a script to create the table, and then run a

insert into
select *

or

create a script to create the table but only copy out the constraint /primary key part of the T-SQL.
Then run select into
then run the T_sql you copied earlier to create the constraint.
 

Users who are viewing this thread

Back
Top Bottom