zoukankan      html  css  js  c++  java
  • 必须声明标量变量 "@tempTable"

    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
    
    --必须声明标量变量 "@mytabe"。
    
    
    
    
    --解决方法
    update test set test.name= ta.name
    from @mytabe as ta
    where test.id=ta.id
    --(4 行受影响)	
    
    
    
    


     

  • 相关阅读:
    刚体动力学
    碰撞检测系统
    动画系统II
    动画系统
    Game Develop Books
    光照技术
    LR参数组取值操作方法
    loadrunner测试ajax框架
    ​Web(click and script) 与 Web(HTTP/HTML)协议区别
    性能测试常用的linux命令
  • 原文地址:https://www.cnblogs.com/dingdingmao/p/3146512.html
Copyright © 2011-2022 走看看