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 2005 Forums
 Transact-SQL (2005)
 Session Variables in Stored Proc

Author  Topic 

ryanlcs
Yak Posting Veteran

62 Posts

Posted - 2009-10-27 : 05:28:57
Hi

Is there a way to generate a "Unique Session variable" key through stored proc? As those unique values generate under ASP.Net.

Thank You.

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-10-27 : 06:44:44
Do you mean unique id's like this??

select convert(varchar,getdate(),112)+replace(convert(varchar,getdate(),114),':','')

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

Eli Kohen
Starting Member

6 Posts

Posted - 2009-10-27 : 07:22:26
Hi. The better way is to use the function NEWID(). The small sample from MSDN below.

DECLARE @myid uniqueidentifier
SET @myid = NEWID()
PRINT 'Value of @myid is: '+ CONVERT(varchar(255), @myid)

-- Result:
-- Value of @myid is: 4FFB0451-5A33-4366-A522-4B14FFD2A80E

Devart team. Database managment and data access solutions.
www.devart.com
Go to Top of Page
   

- Advertisement -