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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving Values from SP 2

Status
Not open for further replies.

durug

Technical User
Mar 22, 2002
335
CA
Hi everybody!

Is there another way in a SP to retrieve values from a select statement other then using a cursor?

like:
select start as @start, end as @end from month
and then later on in the SP to use the @start and @end variable for other purposes.

Right now I'm extracting this values (@start, @end) using a cursor, but I know that the cursor is consuming extra resources

NOTE. The select statement from above will always return a single row.

Thanks,
Durug
 
Try this

--Declare @Start and @end

select @start=start,@end=end
from month

did this work?

dbtech
 
I tryed before and this is the error:

"A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations."

Other idea?

Thanks,
Durug

 
You get this message if all the elements in your select clause are not assignment operations. In other words everything must be assigning a value to a variable. You can't have something like:
select @start = start, end from month
you must have
select @start = start, @end = end from month Durkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top