Click here to Skip to main content
15,509,152 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi all,

I have a table in microsoft sql azure as emp(empid primary key,identity,sal,dept).
I inserted 10 values like:

empid sal dept
1 2000 3
2 3000 2
3 500 1
. ... .
. ... .
. ... .
10 2000 3

Now I deleted empid from 5 to 10.

Now I am inserting new values it's empid taking from 11 as pid(because i given empid as identity).
now the problem is how can i reset the empid identity from 6.

please any body help to me how can achieve this....
Thanks in advance..........


NOTE:
i tried like below:
1)DBCC CHECKIDENT('emp',RESEED,6)
2) SET IDENTITY_INSERT OFF
insert into emp(empid,sal,dept) values(6,3800,5)
SET IDENTITY_INSERT ON
i tried above to-ways but not get solution. so any body help to me how to do this in another way.
Posted
Updated 25-Feb-16 0:36am
v3
Comments
OriginalGriff 1-Jun-12 3:01am    
DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalisation if you want to be taken seriously.
reshi999 2-Mar-15 9:21am    
I am finding it hard taking your comment seriously
OriginalGriff 2-Mar-15 10:19am    
http://en.wikipedia.org/wiki/Etiquette_in_technology

And if you haven't even learned that yet...:sigh:
Member 13940020 11-Jun-20 9:40am    
LOL

1 solution

You have to add the table name in identity insert
SET IDENTITY_INSERT employee ON
Insert INTO employee....
SET IDENTITY_INSERT employee OFF

Link
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900