下面是一个存储过程,目的是将opertb表中添加一个记录.其中@money来自另外一个表
问题是怎样将另一表的查询结果放到@money变量中啊??
在ORACLE中我可如下用,在sql server中提示有错误..
该怎么办呢?CREATE PROCEDURE [whabbit].[s_proc](@val1 bigint,@val2 smallmoney,@val3 char(6) ,@val4 char(3)) AS
begin
DECLARE @money smallmoney
select uslmon into @money from usertb where usnum=@val1 --有错误
insert  opertb values(@val1,@money,@val2,GETDATE(),@val3,@val4)
end

解决方案 »

  1.   

    DECLARE @money smallmoney
    select @money=select uslmon into @money from usertb where usnum=@val1
    要保证select uslmon into @money from usertb where usnum=@val1只能有一条记录,
    否则会出错
      

  2.   

    不行啊!
    select @money=select uslmon into @money from usertb where usnum=@val1
    我是在企业管理器中创建的..语法检查通不过...提示@money附近有错误
      

  3.   

    问题解决了.把语句改为下面的即可...
    select @money=uslmon from usertb where usnum=@val1
    谢谢jilate(李建旭) 
    结贴了...