![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Do I really need to have two connections, one for usual application stuff, and one for getting sequence numbers. or what is the common practice here? |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
Beeing new to sql-server I look for some pointers. I have a system, written for Oracle that uses sequences in order to get a primary key value. I see that that is not supported in sql-server, at least not in 2005. Is there any common practice to deal with this? (Thinking of porting it to sql-server) I know that there is something called auto-increment or so, but as I understand it, its only per table. I want to be able to get a number, and use it as primary key for _several_ tables. And also, it _has_ to be in a transaction of its _own_ , ie setting up a table with sequence_name, min_val max_val and cur_val is not enough, unless it can be reached outside the application transaction. A rollback on application side cannot rollback sequnce number taken out. |
#5
| |||
| |||
|
|
Ok, so if I understand you correctly, you use Ident on a 'useless' table, insert a record, rolls i back, useing savepoint, and then gets the number used by a function call SCOPE_IDENTITY() All in the same connection. Seem like a solution I can use, by creating a 'useless' table for each sequence I need. |
#6
| |||
| |||
|
#7
| |||
| |||
|
|
Keep in mind that SQL Server is not Oracle and vice versa. Trying to implement solutions on SQL Server as if it was Oracle or vice versa, will only lead to frustration. |
#8
| |||
| |||
|
|
So this is an attempt to do the porting to sql-server without too much rewrite |
![]() |
| Thread Tools | |
| Display Modes | |
| |