Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Setting a table identity off through script!

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-02-26 : 23:18:21
Michel writes "To Whom it may concern:

I am using SQL SERVER 2000 and I know I can manually set a table's identity column on or off, if I want to do so (Of Course, there is no use of doing that in production!!!)

Anyways, I don't like deleting information, so I have created similar tables which contain exactly the same info and an extra field. Example:

Company Table
CompanyId, CompanyName

DelCompany Table
DelId, CompanyId, CompanyName

CompanyId is the identity column for the Company Table. If I mistakenly delete a company, I want to put it back without creating a new record. Why? I have over 20 tables which have companyId as foreign Key and if I was to (re) insert this back with a new id, I would have to maintain throughout the other tables. See where I stand... My main problem is 3 of these 20 tables have child tables which also need to be inserted and they have their own identity table...

The idea is to:

set company @@identity off

insert into company (companyId, companyName) select companyId, companyName from delCompany where delId = 1

set company @@identity on

Is there anything I can do?

Please help or else I will have to reevaluate a new solution for my delete scripts.

Thank you,

Michel"
   

- Advertisement -