Must declare a scalar variable & quot; @ tempTable & quot;

Source: Internet
Author: User
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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.