November 21, 2006 at 12:15 pm
Hai
I have a table with auto number in Sql Server. Is that possible to modify that number. Like (EmployeeID)
Thanks
November 21, 2006 at 12:20 pm
Yes and no... what do you need exactly?
November 22, 2006 at 11:23 am
dbcc checkident('tablename',reseed,<seednum>
November 22, 2006 at 11:27 am
If that doesn't help him, it may help someone else someday. .
November 24, 2006 at 4:53 pm
Yes, it is possible to modify the number by first doing a SET IDENTITY INSERT... here's the syntax from Books Online...
SET IDENTITY_INSERT [ database. [ owner. ] ] { table } { ON | OFF }
Don't forget to turn it off when you've completed your update. And, don't forget that it is usually a bad to change the value in an identity column especially if it is a Primary Key... real bad idea...
--Jeff Moden
Change is inevitable... Change for the better is not.
November 25, 2006 at 9:22 am
Hai Jeff
Thanks a lot. It worked out .
By the way why you say that changing the IDENTITY_INSERT value is bad ..? Is there any reasons. .. ?
Webjalam
November 25, 2006 at 9:40 am
If it's the Primary Key, then you may be (will be) destroying referential integrity for other data in other tables. If it's the Primary Key and you don't have referential integrity, then you are in very deep Kimchie... ... that would be very bad database design because you have no guarantee that rows can be made to match up in the future. Think of it like this... you have a bunch of customers in a table that assigns CustID's using the IDENTITY property of the CustID column... you have a process that accepts payments for customers based on the CustID in the Customer table... you change the CustID in the Customer table... if referential integrity is not in place to keep you from doing that, you've just orphaned all the payments those customers made and there's no way to get back.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 25, 2006 at 5:13 pm
well you can ask all those missing payments to be remade... but it might not be a good thing on the long run for the company .
November 26, 2006 at 4:32 pm
Yeah... especially since I might use my pickup to pull a santion out of the building just to get their attention
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 9 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply