SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Alternate Solution?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

bandi
Flowing Fount of Yak Knowledge

India
2217 Posts

Posted - 03/21/2013 :  07:54:16  Show Profile  Reply with Quote
Is ther any alternate solution for the below code... ( for reset the IDENTITY value).....

I dont have permissions for DBCC command..
Eg: DBCC CHECKIDENT ("Person.AddressType", RESEED, 10);

My colleague deleted data by using DELETE statement. so we can't use TRUNCATE approach also

Please let me know the other approaches...

--
Chandu

RickD
Slow But Sure Yak Herding Master

United Kingdom
3608 Posts

Posted - 03/21/2013 :  08:07:40  Show Profile  Reply with Quote
why can't you use truncate? Even if there is no data, you should still be able to use it.
Go to Top of Page

DonAtWork
Flowing Fount of Yak Knowledge

2161 Posts

Posted - 03/21/2013 :  10:36:30  Show Profile  Reply with Quote
Ultra drastic: Drop table, recreate








How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30265 Posts

Posted - 03/21/2013 :  11:53:02  Show Profile  Visit SwePeso's Homepage  Reply with Quote
The real question is "Why do you care about gaps in the identity column?"...


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2217 Posts

Posted - 03/22/2013 :  01:06:25  Show Profile  Reply with Quote
DonAtWork --> we don't have permissions to DROP and CREATE ( even don't have DBCC permission in development Server)

SwePeso --> we have to insert new actual data into server after deletion of old data



--
Chandu
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2217 Posts

Posted - 03/22/2013 :  01:14:10  Show Profile  Reply with Quote
quote:
Originally posted by RickD

why can't you use truncate? Even if there is no data, you should still be able to use it.



My table which has identity column is child table ( depending on many tables..)
So i can't use TRUNCATE command for that table

--
Chandu
Go to Top of Page

Lamprey
Flowing Fount of Yak Knowledge

4614 Posts

Posted - 03/22/2013 :  13:20:13  Show Profile  Reply with Quote
quote:
Originally posted by bandi

SwePeso --> we have to insert new actual data into server after deletion of old data

--
Chandu

That doesn't really answer the question. Are you saying that you are inserting data and need to control the identity? If so, then aren't you already overridding the identity? (IDENITY INSERT) If not, then what Peso is asking is: What difference does it make what the Identity value is?

The identity value doesn't/shouldn't matter. If it does matter then I'd question the design. Do all the deletes you want and don't worry about the idenity value.

I realize this probalby isn't want you are looking for, but here is an article by Peso on how to reuse IDs:
http://www.sqlteam.com/article/efficiently-reuse-gaps-in-an-identity-column
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000