IDENTITY / SCOPE_IDENTITY

G

Guest

I have and application that I would like to reset the IDENTITY VALUE. Is
there a way to change it in C# .NET? My application uses SQL Server 2000.

Thanks in Advance.
 
W

William \(Bill\) Vaughn

What do you plan to do with existing data?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
G

Guest

Using DBCC commands, you can play with the IDENTITY values. I have done it
from C#, but it is better to embed the command in a sproc for reusability.

Realize that resetting the IDENTITY can be a dangerous operation. We did it
to increment and "backfill" numbers, so it was not "as" dangerous. Make sure
you have thought through what you are doing before heading this direction.
The BOL for SQL will help you do this.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
G

Guest

The reason that I do this is because I have two tables that are locked
together in a relationship. I will not change the primary key, just the
secondary key. I wont to have the secondary key reset every time the primary
changes (insert). Can you point me to a place where I can see how to do this
in a SP.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top