I'm trying to set a couple of variables, one is a name of the table (@table), the other one is a string.
I've got the error message:
Must declare the table variable "@table".
as far as I could understand it's because I must use @table as a table variable, but I just need it as a string
declare @a varchar(50);
declare @table varchar(100);
select @table =
case
WHEN Version = 'Advanced' THEN ("tableadv")
WHEN Version = 'Professional' THEN ("tablepro")
WHEN Version = 'Light' THEN ("tablelight")
WHEN Version = 'Short' THEN ("tableshort")
END
FROM partno where inpn=3
set @a = (select top (1) LicenseNumber from @table where used is null)
insert into seriali (LicenseNumber, idpn, serdgtrace)
select @a, 2, 'DAT-enrico'
update @table set used = 1 where LicenseNumber=@a
any help will be appreciated. Many thanks, enrico