日期:2014-05-17 浏览次数:20366 次
DECLARE @shuliang int
SET @shuliang = 0
SELECT @shuliang = SUM(CONVERT (INT, [yingtuishu]))
FROM [Faliaominxi]
WHERE [liaohao] = @liaohao
AND [mark] = '0'
AND [faliaodan] <> @faliaodan
IF(@shuliang=NULL)或者是
Begin
set @shuliang=0
End
IF(@shuliang='')都不成功,我更改数据类型后使用
Begin
set @shuliang=0
End
IF(convert(nvarchar(50), @shuliang)=NULL)或者是
Begin
set @shuliang=0
End
IF(convert(nvarchar(50), @shuliang)='')也不行 请高手指点下,当INT型的数据类型,没有获取到任何数据的时候,需要怎么来给变量赋值?
Begin
set @shuliang=0
End
DECLARE @shuliang int
SET @shuliang = 0
SELECT @shuliang = isnull(SUM(CONVERT (INT, [yingtuishu])),0)--这样转化过后是不会出现''的情况
FROM [Faliaominxi]
WHERE [liaohao] = @liaohao
AND [mark] = '0'
AND [faliaodan] <> @faliaodan
DECLARE @shuliang int
SET @shuliang = 0
SELECT @shuliang = SUM(cast( ISNULL([yingtuishu],0) as INT))
FROM [Faliaominxi]
WHERE [liaohao] = @liaohao
AND [mark] = '0'
AND [faliaodan] <> @faliaodan
@shuliang=NULL --@shuliang is NULL