日期:2014-05-18  浏览次数:20538 次

即急!求教一个sql语句
insert into dbo.T_Money values((select ti.ID from dbo.T_Item as ti where ti.item=@itemp),@moneyp,@datetimep,@username,@remarkp)


这个sql语句执行起来总是说。子查询错误。。。求应该怎么改。。。

------解决方案--------------------
SQL code
insert into dbo.T_Money values((select TOP 1 ti.ID from dbo.T_Item as ti where ti.item=@itemp),@moneyp,@datetimep,@username,@remarkp)

------解决方案--------------------
SQL code

INSERT  INTO dbo.T_Money
        SELECT  ( SELECT    ti.ID
                  FROM      dbo.T_Item AS ti
                  WHERE     ti.item = @itemp
                ) ,
                @moneyp ,
                @datetimep ,
                @username ,
                @remarkp

------解决方案--------------------
insert into dbo.T_Money 
select ti.ID ,@moneyp,@datetimep,@username,@remarkp
from dbo.T_Item as ti where ti.item=@itemp
------解决方案--------------------
SQL code

insert into dbo.T_Money 
select ti.ID ,@moneyp,@datetimep,@username,@remarkp
from dob.T_Item as ti where ti.item = @itemp

------解决方案--------------------
insert into dbo.T_Money 
select (select ti.ID from dbo.T_Item as ti where ti.item=@itemp),@moneyp,@datetimep,@username,@remarkp
弄错了

------解决方案--------------------
SQL code
INSERT  INTO dbo.T_Money
        SELECT  ti.ID, @moneyp, @datetimep, @username, @remarkp
        FROM    dbo.T_Item AS ti
        WHERE   ti.item = @itemp

------解决方案--------------------
SQL code
insert into dbo.T_Money values(
(select top 1 ti.ID from dbo.T_Item as ti where ti.item=@itemp)
,@moneyp,@datetimep,@username,@remarkp
)