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)
 Storing the latest GUID value in a stored procedur

Author  Topic 

pras2007
Posting Yak Master

216 Posts

Posted - 2009-06-09 : 15:31:29

I’ve created a GUID (uniqueidentifier) field that auto-generates; The problem is that I want to pass the latest GUID value in a stored procedure, but I’m having problems doing so. In the same record set I have a field that stores date values, maybe I can track down the latest date value then can select the latest GUID values. Below is an example of the table in question. Please advice. Thanks.

Example
REC_ID REC_Date
354071EA-2392-4216-B970-8A7E5EF9F174 2009-06-09 09:14:46.040
FB60940A-CDBF-48A3-8534-9040243FFE11 2009-06-09 14:19:05.083

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-09 : 15:47:32
select top 1 REC_ID
from table
order by REC_Date DESC


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Skorch
Constraint Violating Yak Guru

300 Posts

Posted - 2009-06-09 : 15:48:26
SELECT TOP 1 REC_ID
FROM YourTable
ORDER BY REC_Date DESC

Looks like I was late :)

Some days you're the dog, and some days you're the fire hydrant.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-09 : 15:53:29
In most cases I am toooo late and in this case I am the dog


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -