barnesco
asked on
Returning parameter from a select statement
How do I return the below to a parameter:
DECLARE @ReturnCOID int
SELECT COID FROM Order
DECLARE @ReturnCOID int
SELECT COID FROM Order
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Important in dbbisshop's comment
"Note that this must return only one row"
If that is possible causing problems there are ways around that , but see they still give a correct value in all cases for what you intend to do.
Some examples
"Note that this must return only one row"
If that is possible causing problems there are ways around that , but see they still give a correct value in all cases for what you intend to do.
Some examples
Select @ReturnCOID = max(COID) from Order
or Select @ReturnCOID = top 1 COID from Order order by orderdate desc
it should like
select @ReturnCOID=COID FROM Order .