Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Sequence Number

Author  Topic 

saiabhiram
Starting Member

17 Posts

Posted - 2010-05-15 : 23:54:48
Hello I am inserting records into a table.

In that table there is field called Sequence Number. The Sequence Number should be incremented for every record inserted. How can I do that.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-05-16 : 01:28:53
make the Sequence Number an identity field


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-16 : 07:33:33
can you specify by means of data sample how you want it to increment. if its just incrementing over entire table then identity is enough. if you want this to happen within groups look for ROW_NUMBER() function

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -