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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Finding number assigned with auto increment

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-04-16 : 00:20:08
Eric writes "I am running MS SQL 7.0 on NT Server 4.0. I have done extensive SQL development, however have never found a satisfying answer to my question. I have a database of users that assigns a userID when the record is created using auto numbering. I then use this number for all other references rather than the username (such as logging, security rights mapping, etc.). When I create the new record, SQL assigns the record the next number in the sequence.

My question is how do I find out what number was assigned? I have gotten around this for many years by performing the insert then going back with a select query on the username to get the unique ID. This seems unelegant, and a double hit on the DB server. Is this the best/only way around this?"
   

- Advertisement -