Basically I want to do a query that will return the first value in the table queried and put it into a variable. How do I do this?
Thanks in advance.
SELECT
top 1 yourColFROM
T1ORDER
BYyourCol|||Well that returns a table with the first record BUT I wanted the thing returned as a value.Say I declared a integer variable with
DECLARE @.x, I wanted the integer variable to be equal to the first record which would be an "age" column in the recordset
SELECT age FROM PEOPLE
I can't do @.x=SELECT age FROM people|||
CREATE
PROCEDURE [dbo].[sp__top1Name]@.myAge
intOUTPUTASBEGIN
SET @.myAge=(SELECTtop 1 Agefrom T1ORDERBY Age)END
In your code, you need to grab this value from stored procedure OUTPUT parameter which is the age you are looking for.
No comments:
Post a Comment