> 데이터 베이스 > MySQL 튜토리얼 > 必须声明标量变量 "@tempTable"

必须声明标量变量 "@tempTable"

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
풀어 주다: 2016-06-07 15:14:58
원래의
7831명이 탐색했습니다.

MLGB 微软的sqlserver有一个BUG,在使用表 变量 进行修改时,他会提醒你: 必须 声明 标量 变量 @tempTable。 首先 /*create table test(id int identity(1,1),name varchar(10))insert into test select '222'union select '444'union select '455'*/godecl

MLGB

微软的sqlserver有一个BUG,在使用表变量进行修改时,他会提醒你:

必须声明标量变量 "@tempTable"。

 

 

 

首先

/*create table test
(
	id int identity(1,1),
	name varchar(10)
)

insert into test
	  select '222'
union select '444'
union select '455'
*/
go
declare @mytabe table(
	id int,
	name varchar(10)
)

insert into @mytabe
	   select 1,'123'
union  select 2,'123'
union  select 4,'123'
union  select 6,'123'

-- 删除 
delete from test
	where id not in
	(
		select id from @mytabe
	)
	
--(4 行受影响)

--(1 行受影响)

-- 增加
insert into test
	select name from @mytabe
	
--(4 行受影响)

--修改

update test set test.name= @mytabe.name
from @mytabe
where test.id=@mytabe.id

--<strong>必须</strong><strong>声明</strong><strong>标量</strong><strong>变量</strong> "@mytabe"。




--解决方法
update test set test.name= ta.name
from @mytabe as ta
where test.id=ta.id
--(4 行受影响)	



로그인 후 복사


 

 

 

관련 라벨:
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿