Sathiya Vasagam S
Sathiya Vasagam S

Reputation: 114

How to generate next sequence value with in my insert statement in hibernate?

If its in my sql server procedure means, I assign like following for particular table:

select @id=NEXT value FOR sq_id;

Now for same sequence value I need to do and insert some other column values also for a particular table using spring-hibernate So I need the insert query with generate next sequence value for a particular table..!

Upvotes: 0

Views: 996

Answers (1)

Kannan Kandasamy
Kannan Kandasamy

Reputation: 13959

You can use create sequence in sql server:

CREATE SEQUENCE Test.TestSequence
START WITH 1  
INCREMENT BY 1 ; 

For next value we can use SELECT NEXT VALUE FOR Test.TestSequence

We can make cylic sequence, any increments any starting point or ending point etc.,

Upvotes: 0

Related Questions