Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing the result from a select statement into a variable

Status
Not open for further replies.

DwayneL

Technical User
Feb 26, 2002
23
CA
Hellp there
I need to know how to store the result of a select statment into a variable. Is this even possible?

Here is the code I'm trying to work with.

Declare @LastResNumber as varchar(8)

Set @LastResNumber = Select max(ReservationNum) from Booking

ReservationNum is also varchar(8)
 
Instead of SET, Use:
SELECT @LastResNumber = (SELECT MAX(ReservationNum)FROM Booking )
 
dwaynel, try this
Select @LastResNumber = max(ReservationNum)
from Booking

 
Thanks guys, dang brackets, who would have thought
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top