MLGB Microsoft sqlserver has a BUG. When using Table variables for modification, it will remind you that the scalar variable @ tempTable must be declared. First, * createtabletest (idintidentity (1,1), namevarchar (10) insertintotestselect222unionselect444unionselect455 * godecl
MLGB Microsoft sqlserver has a BUG. When using Table variables for modification, it will remind you that the scalar variable @ tempTable must be declared. First/* create table test (id int identity (222), name varchar (10) insert into test select '000000' union select '000000' union select '000000' */godecl
MLGB
Microsoft SQL Server has a BUG in using tables.VariableWhen making the changes, he will remind you:
RequiredStatementScalarVariable"@ TempTable ".
First
/* Create table test (id int identity (1, 1), name varchar (10 )) insert into test select '000000' union select '000000' union select '000000' */godeclare @ mytabe table (id int, name varchar (10) insert into @ mytabe select 1, '20180101' union select 2, '20180101' union select 4, '20180101' union select 6, '20180101' -- delete from testwhere id not in (select id from @ mytabe) -- (four rows affected) -- (one row affected) -- add insert into testselect name from @ mytabe -- (four rows affected) -- modify update test set test. name = @ mytabe. namefrom @ mytabewhere test. id = @ mytabe. id --RequiredStatementScalarVariable"@ Mytabe ". -- Solution: update test set test. name = ta. namefrom @ mytabe as tawhere test. id = ta. id -- (four rows are affected)