I have a table that has a auto incremented primary key. Now for some reason, a record was deleted and was causing some errors on other parts of the website. THere are other tables that references this primary key. Can I manually insert a record into this
table with a specific id instead of using the auto increment identity key?
e.g
Auto ID Name Address
1 John Doe 1234 Street
3 Jane Doe 5432 Road
I need to insert a row with these values ('2', 'Test', '1234 Road')
amosCabanban...
Member
441 Points
142 Posts
Inserting a row with a fixed identity
Jun 25, 2012 04:15 PM|LINK
I have a table that has a auto incremented primary key. Now for some reason, a record was deleted and was causing some errors on other parts of the website. THere are other tables that references this primary key. Can I manually insert a record into this table with a specific id instead of using the auto increment identity key?
e.g
Auto ID Name Address
1 John Doe 1234 Street
3 Jane Doe 5432 Road
I need to insert a row with these values ('2', 'Test', '1234 Road')
tarunSaini
Contributor
2948 Points
985 Posts
Re: Inserting a row with a fixed identity
Jun 25, 2012 04:31 PM|LINK
SET IDENTITY_INSERT tablename ON
YOUR INSERT GOES HERE
SET IDENTITY_INSERT tablename OFF
amosCabanban...
Member
441 Points
142 Posts
Re: Inserting a row with a fixed identity
Jun 25, 2012 05:04 PM|LINK
Thanks!