Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Very Quick Replace q

Author  Topic 

PanzerAttack
Yak Posting Veteran

71 Posts

Posted - 2011-09-06 : 08:12:07
I have this

REPLACE(DisputeCaseReasonCode,"NULL","ZXX")

in a Derived field in the SSIS package. Some of the DisputeCaseReasonCode are coming through blank, and where this is happening, I want to assign the code ZXX.

Have I done something wrong as it's not updating the field.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-06 : 08:15:43
it should be
COALESCE(NULLIF(DisputeCaseReasonCode,''),'ZXX')

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

PanzerAttack
Yak Posting Veteran

71 Posts

Posted - 2011-09-06 : 08:23:18
Thanks for the very quick response, I get an error I'm afraid:

Error at Data Flow Task [Import Date Derived 1 1 1 1 1 [17]]: Parsing the expression "COALESCE(NULLIF(DisputeCaseReasonCode,''),'ZXX')" failed. The single quotation mark at line number "1", character number "39", was not expected.

Error at Data Flow Task [Import Date Derived 1 1 1 1 1 [17]]: Cannot parse the expression "COALESCE(NULLIF(DisputeCaseReasonCode,''),'ZXX')". The expression was not valid, or there is an out-of-memory error.

Error at Data Flow Task [Import Date Derived 1 1 1 1 1 [17]]: The expression "COALESCE(NULLIF(DisputeCaseReasonCode,''),'ZXX')" on "output column "DisputeCaseReasonCode1" (167)" is not valid.

Error at Data Flow Task [Import Date Derived 1 1 1 1 1 [17]]: Failed to set property "Expression" on "output column "DisputeCaseReasonCode1" (167)".

(Microsoft Visual Studio)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-06 : 08:37:09
ok so you're doing this in ssis derived column. you could have specified that.
if thats the case try

(ISNULL(DisputeCaseReasonCode) || DisputeCaseReasonCode=="")? (DT_WSTR,100)"ZXX" : DisputeCaseReasonCode

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

PanzerAttack
Yak Posting Veteran

71 Posts

Posted - 2011-09-06 : 09:17:16
It worked perfectly, thank you
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-06 : 11:09:13
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -