DECLARE @a Int,
SET @a = (SELECT TOP 1 UserTableID 1 AS FisNo
FROM ET_MalzemeveHareketleri
ORDER BY UserTableID DESC)
SELECT @a
This is the code I have a table id of 4000 thousand rows, I want to load the last number into the @a
variable.
CodePudding user response:
declare @a Int;
----IF Identity is mentained as 1-1
SELECT @a=(SELECT TOP 1 UserTableID FROM ET_MalzemeveHareketleri order by UserTableID desc);
----IF Identity is not mentained
SELECT @a=(SELECT IDENT_CURRENT('ET_MalzemeveHareketleri'));
select @a
CodePudding user response:
Do something like this
declare @a Int;
select @a = colname
from table
where ...
;