ZURINET
asked on
ISNULL value replacement , withing a string
Hi all
I looking for a way to replace a column
if the value is NULL with an alternate value
Since I need to assign the select statement to a variable..
The current formating I got, is not working see code below
I looking for a way to replace a column
if the value is NULL with an alternate value
Since I need to assign the select statement to a variable..
The current formating I got, is not working see code below
declare
@ErrorMessage varchar(25)
set @ErrorMessage = 'This is a 2248 Error'
SET @sql_trans_VProtokoll = ' SELECT i.EBILL as Transaction,SUBSTRING(h.zeichnung,1,15) as Zeichnung,
ISNULL(i.infoText, ''' + @ErrorMessage + ''') as ReasonText '
What error are you getting?
ASKER
Hallo RajkumarGS
What is the difference between my code and yours?
My problem is that the msg @ErrorMessage = 'This is a 2248 Error'
is not returned..
The query is returning -- null
What is the difference between my code and yours?
My problem is that the msg @ErrorMessage = 'This is a 2248 Error'
is not returned..
The query is returning -- null
How have you defined @sql_trans_VProtokoll?
Here is the solution
declare @ErrorMessage varchar(25)
declare @sql_trans_VProtokoll varchar(max)
set @ErrorMessage = 'This is a 2248 Error'
SET @sql_trans_VProtokoll = ' SELECT i.EBILL as ''Transaction'',SUBSTRING( h.zeichnun g,1,15) as Zeichnung,
ISNULL(i.infoText, ''' + @ErrorMessage + ''') as ReasonText '
print (@sql_trans_VProtokoll)
--exec (@sql_trans_VProtokoll)
declare @ErrorMessage varchar(25)
declare @sql_trans_VProtokoll varchar(max)
set @ErrorMessage = 'This is a 2248 Error'
SET @sql_trans_VProtokoll = ' SELECT i.EBILL as ''Transaction'',SUBSTRING(
ISNULL(i.infoText, ''' + @ErrorMessage + ''') as ReasonText '
print (@sql_trans_VProtokoll)
--exec (@sql_trans_VProtokoll)
ASKER
Find where the problem lies...
The infoText is declared as sql data type text
and the value inside is NULL string.. and not null
Wondering how I can solve this now?
The infoText is declared as sql data type text
and the value inside is NULL string.. and not null
Wondering how I can solve this now?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The problem lies in the data I have in the database
Open in new window