我想在存储过程中执行这样的语句,获取某表中top 1 的数据。
select top 1 @id = id,@cardid=cardid,@username = username orderdish  order by id desc
这样貌似不行,

解决方案 »

  1.   

    是我刚才写错,其实我在代码里面是有from 的,请高手帮忙
      

  2.   

    那就不會錯撒declare @t table (id int,value varchar(10))
    insert into @t select 1,'a'
    insert into @t select 2,'b'
    insert into @t select 3,'c'declare @id int,@value varchar(10)
    select top 1 @id=id,@value=value  from @t order by id desc
    print @id
    print @value/*
    ----
    3
    c*/