sql server - How to copy table to another table? -


i have table 1 000 000 records:

create table [dbo].[x2](     [session_id] [uniqueidentifier] not null,     [node_id] [uniqueidentifier] not null,     [id] [int] identity(1,1) not null,  constraint [pk_x2] primary key clustered  (     [id] asc )); 

i need replace field

[id] [int] identity(1,1) 

with

[id] [bigint] identity(1,1) 

but data (including id values) should copied new table , id should identity bigint.

i have created new table

create table [dbo].[x2_new](     [session_id] [uniqueidentifier] not null,     [node_id] [uniqueidentifier] not null,     [id] [bigint] identity(1,1) not null,  constraint [pk_x2_new] primary key clustered  (     [id] asc )); 

and tried copy data:

insert x2_new(session_id,node_id,id) select session_id,node_id,id x2; 

but slow. how copy data new table faster?

in case.. need 'identity_insert off' on destination , insert script.. try setting nolock too.. 1 time activity or repetitive one?


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -