Print | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Print

HI,I want print result of select Declare @volN int
set select @volN = volN from linTMP where va1X =cast(right(@va1X ,9) as int)
PRINT ‘Result of volN = ‘+cast( @volN as varchar(20)) +’ **** ‘ When result of @volNMinuty is some value it is printed ..Result of volN = 100 But when result hasn’t some value , result of print is nothing. String ‘Result of volN = ‘ is not written.
It’s a pitty, because i need print some values during procedure. Lubo
If @VolN is NULL, the concatenation fails … PRINT ‘Result of volN = ‘ + CASE WHEN @VolN IS NULL THEN ‘ -unknown- ‘ ELSE cast( @volN as varchar(20)) END +’ **** ‘
Yes if you concatenate a string with NULL and prints then it will be nothing Declare @volN int
set select @volN = volN from linTMP where va1X =cast(right(@va1X ,9) as int)
if (isnull(@volN,0)=0)
begin
PRINT ‘Result of volN NOTHING ‘
end
else
begin
PRINT ‘Result of volN =’+convert(varchar(10),@volN)
end
Here is simpler form of Adriaan’s declare @p varchar(10)
Print ‘Result =’+Isnull(@p,’unknown’)
Madhivanan Failing to plan is Planning to fail
]]>