How to get the last record .. Stored Procedure?
-
Hay .. in SQL server 2005 I can make any select statement , but how can I get the last record : like that id invNo 1 a1 2 a2 3 a3
@newinv nvarchar(10) output AS SET NOCOUNT ON begin SELECT * FROM table ORDER BY invNo end
I want to get the field invNo of the last record then by substring function i can add One .. I hope my question is clear . thanksjooooo
-
Hay .. in SQL server 2005 I can make any select statement , but how can I get the last record : like that id invNo 1 a1 2 a2 3 a3
@newinv nvarchar(10) output AS SET NOCOUNT ON begin SELECT * FROM table ORDER BY invNo end
I want to get the field invNo of the last record then by substring function i can add One .. I hope my question is clear . thanksjooooo
-
Hay .. in SQL server 2005 I can make any select statement , but how can I get the last record : like that id invNo 1 a1 2 a2 3 a3
@newinv nvarchar(10) output AS SET NOCOUNT ON begin SELECT * FROM table ORDER BY invNo end
I want to get the field invNo of the last record then by substring function i can add One .. I hope my question is clear . thanksjooooo
"select top 1 InvNo from table order by id DESC" -- ASSUMES ID IS AN IDENTIY FIELD, OPR AT LEAST THAT THE LAST RECORD HAS THE HIGHEST id
-
select top 1 invNo from table order by id desc
I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.
Great minds think alike...:-\
-
"select top 1 InvNo from table order by id DESC" -- ASSUMES ID IS AN IDENTIY FIELD, OPR AT LEAST THAT THE LAST RECORD HAS THE HIGHEST id