Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want reset the S.No for every month. For Every month it will start from 1 and the maximum id value for one month is 9999.

Please reply as soon as possible.
Thank You
Posted
Comments
Sergey Alexandrovich Kryukov 14-Aug-15 2:40am    
This is a really bad idea. Don't do it.
—SA
Mekalamani 14-Aug-15 2:44am    
can you know please send that code
Thanking You
Advay Pandya 14-Aug-15 3:06am    
Please provide some more details on this. Reset means when ? While inserting data or while fetching data? and what to do if the number exceeds 9999 for a month ?
Mekalamani 14-Aug-15 3:25am    
Reset means again start with 1.if number exceeds above 9999 means again start with 1.
Advay Pandya 14-Aug-15 4:56am    
ya, but while inserting in the table or just fetching data using select statement ?

1 solution

If your are trying to reset the identity column it is a bad idea though there is a way to reset it using DBCC command moreover it shouldn't be your primary key.

Or if it is just a normal column to maintain the incremental number then check for the last id if it is exceeding 9999 and then insert it with 1 again.
 
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