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
 Transact-SQL (2000)
 Want to use unique id for each user

Author  Topic 

Utpal
Posting Yak Master

179 Posts

Posted - 2002-07-26 : 08:25:21
Hi everybody,
I am trying to create a stored procedure that would first insert rows into a table and later retrieve the rows from it (using SELECT). But for this to work with 2 or more users, an unique id for each user would have to be stored in each row and while retrieving the rows, the rows would have to be filtered based on the unique id. Is there any function that would return an unique id for each user, suitable for this purpose ?

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-07-26 : 08:29:59
Just use a regular Identity column. You can get the newly inserted values using @@IDENTITY, or if you have multiple rows, inside a trigger using the inserted pseudo-table. Each user's session is independent of the other and won't see each other's values.

You can also use SCOPE_IDENTITY to ensure you're getting values from the current session only.

Have you read this yet?

http://www.sqlteam.com/item.asp?ItemID=8003

Go to Top of Page

Utpal
Posting Yak Master

179 Posts

Posted - 2002-07-26 : 08:59:18
Thanks Robvolk ! I have read that article now. I got your idea. I just came across a function SUSER_SID, that returns the user's login identificaton number. Can't I use that ?




Edited by - Utpal on 07/26/2002 09:01:43

Edited by - Utpal on 07/26/2002 09:03:21
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-07-26 : 09:09:50
Sure you can use it. What I'm saying is that you don't need it. At least I don't see why you would. You'll have to post more detail about what you're trying to do, including your table structures and any code or SQL you have now.

Go to Top of Page
   

- Advertisement -