declare @us table(name nvarchar(100),lastname nvarchar(100),UID bigint,available bit);
declare
@Name nvarchar(100),
@lastname nvarchar(100),
@UID bigint,
@Avail bit
insert into @us
select @name=name,@lastname=lastname,@UID=UID,@Avail=available from Users where available='1'
select * from @us
I got this error
An INSERT statement cannot contain a SELECT statement that assigns
values to a variable.
I searched for this problem but many people used queries like this and they said there is no problem! i'm using sql server 2012, is it a deference between MSSQL2012 and MSSQL2008? and what is the best solution if I want to return a table from my Stored Procedures? what is wrong in my query?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…