Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable Indentity Field ADO

Status
Not open for further replies.

dokken

Programmer
Mar 7, 2001
61
US
I have an ASP application that uses ADO to manipulate a SQL server database. I have made all PK fields Identity fields so the DB an take care of assigning the values. I also would like to be able to run an ASP script that copies our production data to our test database. I would like to retain the PK values. How can I easily temporarily turn off the identity fields so I can write to the PK field via my ASP page. Is there an ADO command to do this?

Thanks
Paul
 
The easiest way is NOT to set the Primary Key for the test database..I mean, you should not have IDENTITY for any column definitions in your test table. Rather a Field by name ID and a Long Integer or whatever. Manually insert the ID from Original to Test via the Insert statement.

Let me know if this helps...





Thank you...
RR

 
SQL Books Online describes a database property that might enable this.

SET IDENTITY_INSERT [database.[owner.]]{table} {ON | OFF}

 
RR,
I need to have the identity column. This is the only way the column gets set when I insert a new record. The code will break if I don't have it.

Does anybody know how I could execute this statement: SET IDENTITY_INSERT [database.[owner.]]{table} {ON | OFF}

via ADO in an ASP page?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top