1.
DECLARE @Camount int
set @Camount='select a.pro_amount from pdm_product A'
UPdate PPV
set
pro_amount=pro_amount-@Camount
怎样写才是正确的.
---------------------------------------------------
2.我用下面的方法取得返回值,如果当数据表里没有数据时,就会出错,如何初始一个值呢?
@intRecordCount int output
AS
set @sql='select @outinted=Cast(Right(chitty_code,4) as int)+1 FROM scm_chitty'
EXEC sp_executesql @sql,N'@outinted int output',@intRecordCount output
GO
谢谢大家
DECLARE @Camount int
set @Camount='select a.pro_amount from pdm_product A'
UPdate PPV
set
pro_amount=pro_amount-@Camount
怎样写才是正确的.
---------------------------------------------------
2.我用下面的方法取得返回值,如果当数据表里没有数据时,就会出错,如何初始一个值呢?
@intRecordCount int output
AS
set @sql='select @outinted=Cast(Right(chitty_code,4) as int)+1 FROM scm_chitty'
EXEC sp_executesql @sql,N'@outinted int output',@intRecordCount output
GO
谢谢大家
DECLARE @Camount int
select @Camount=pro_amount from pdm_product
UPdate PPV
set
pro_amount=pro_amount-@Camount
DECLARE @Camount int
set @Camount=(select top 1 pro_amount from pdm_product)
UPdate PPV
set pro_amount=pro_amount-@Camount
DECLARE @Camount int
select @Camount= a.pro_amount from pdm_product A
UPdate PPV
set
pro_amount=pro_amount-@Camount
2.
@intRecordCount int output
AS
set @sql='select @outinted=Cast(Right(isnull(chitty_code,'000000'),4) as int)+1 FROM scm_chitty'
EXEC sp_executesql @sql,N'@outinted int output',@intRecordCount output
GO
@intRecordCount int = 0 output
set pro_amount=pro_amount-(select top 1 pro_amount from pdm_product)
set pro_amount=pro_amount-(select top 1 isnull(pro_amount,0) from pdm_product) --加个isnull判断一下就可以了
set @sql='if not exists(select Cast(Right(chitty_code,4) as int)+1 FROM scm_chitty)
set @outinted=null
else
select @outinted=Cast(Right(chitty_code,4) as int)+1 FROM scm_chitty'
select @Camount= a.pro_amount from pdm_product A
UPdate PPV
set
pro_id=?
pro_amount=?
我想得到是:更新的值是从另一个数据表中得到.请问如何得到.就像这种方式
INSERT INTO scm_item
(pro_id,pro_amount)
SELECT a.pro_id,a.pro_amount
FROM
scm_item A