Connecting Tech Pros Worldwide Forums | Help | Site Map

sequence in MS SQL

Newbie
 
Join Date: Nov 2008
Posts: 14
#1: Nov 30 '08
Im using MS SQL Server as my database in a java application. I want to have something like sequence(of Oracle) in MS SQL. But I left with nothing.

Is there any way to have a variable in MS SQL which is incremented automatically like a sequence(of Oracle)
OR
should I go for a procedure for this purpose?

ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#2: Dec 2 '08

re: sequence in MS SQL


Quote:

Originally Posted by tiijnar View Post

Im using MS SQL Server as my database in a java application. I want to have something like sequence(of Oracle) in MS SQL. But I left with nothing.

Is there any way to have a variable in MS SQL which is incremented automatically like a sequence(of Oracle)
OR
should I go for a procedure for this purpose?

Variable, you might need to manually increment it inside your loop.

Column, yes. Consider IDENTITY property of an numeric column.

-- CK
Reply