我在写存储过程的时候用到
- SQL code
declare @productid varchar(300)set @productid=(select from vw_bill_list)报错 服务器: 消息 512,级别 16,状态 1,过程 BILL_FEE,行 31子查询返回的值多于一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。
执行select product from vw_bill_list 结果是
product
45
46
结果有多个不能用set赋值,
[email protected]='45,46'
帮帮忙这怎么写
我用的SqlServer
------解决方案--------------------
好像要用游标
------解决方案--------------------
- SQL code
declare @productid varchar(300)set @productid=('select * from vw_bill_list')
------解决方案--------------------
用游標了
------解决方案--------------------
- SQL code
declare @productid varchar(300)select @productid= isnull(@productid+',','') + cast(product as varchar(20))from vw_bill_listprint @productid
------解决方案--------------------
- SQL code
--支持海爷declare @productid varchar(300)select @productid= isnull(@productid+',','') + cast(product as varchar(20))from vw_bill_listexec(@productid)
------解决方案--------------------
- SQL code
declare @productid varchar(300)select @productid=isnull(@productid+',','')+ ltrim(product) from tbprint @productid
------解决方案--------------------