declare @uphm intdeclare @t table(hm int)
insert into @t(hm)(select news_HM as hm from news where news_bm='0001')创建了一个临时表@t,并且加入了一条数据问题现在我想让@uphm等于@t中的hm,该如何写,换句话说就是我如何取到@t表中的某行某列的值
set @[email protected]
这种写法出现了"必须声明变量@t"错误

解决方案 »

  1.   

    declare @uphm intdeclare @t table(hm int)
    insert into @t(hm)(select news_HM as hm from news where news_bm='0001')select @uphm=hm from @tselect @uphm
      

  2.   

    declare @uphm intdeclare @t table(hm int)
    insert into @t(hm)(select news_HM as hm from news where news_bm='0001')
    select @uphm=hm from @t
    如果hm有多个值要怎么取?
      

  3.   

    select @uphm = hm from @t 
      

  4.   

    declare @uphm intdeclare @t table(hm int)
    insert into @t(hm)(select news_HM as hm from news where news_bm='0001')select @uphm = hm from @t where ...