views:

17

answers:

2

Hi, i have 2 table

User (id, name, surname,cod)

UserNew (uid, uname, usurname, ucod)

The first table has data the second no.

I have to copy the data of the User table in the UserNew table.

I've tried with a insert query but uid (primary key) value changes.

How can i do to mantaince the same values?

thanks

A: 

I'm guessing that uid of the UserNew table is an identity (autoincrement) column. So you could issue a SET IDENTITY_INSERT UserNew ON statement, then insert the data (including the correct id) and then issue a SET IDENTITY_INSERT UserNew OFF

klausbyskov
A: 

You need to enable

SET IDENTITY_INSERT tablename ON

http://msdn.microsoft.com/en-us/library/aa259221(SQL.80).aspx

Imre L