首页 > 数据库 > mysql教程 > 必须声明标量变量 "@tempTable"

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
发布: 2016-06-07 15:14:58
原创
7832 人浏览过

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
最新问题
PHP 必须会什么才能找工作
来自于 1970-01-01 08:00:00
0
0
0
如果使用captcha,必须要安装composer吗
来自于 1970-01-01 08:00:00
0
0
0
ios - Weex必须用Cocopods配置环境吗
来自于 1970-01-01 08:00:00
0
0
0
这个是必须上传到服务器上面测试的
来自于 1970-01-01 08:00:00
0
0
0
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板