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)
 Adding a String columns.,

Author  Topic 

8022421
Starting Member

45 Posts

Posted - 2009-02-24 : 13:40:19
Hi,
I have a table with a column named cancel_reason. The column is valued as empty for a particular policy. I have another column called transltor_data in the same table. The update script for the same is shown below.

UPDATE MYTABLE
SET translator_data = CANCEL_REASON + '01'
WHERE POLICY_NUMBER = '324'

When do the above update the value I expect is 01. But the output I am getting is empty. Is there any reason for this..Or is there any thing wrong that I am doing here..Please advise.


sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-24 : 13:45:16
what are datatype for columns?
Go to Top of Page

8022421
Starting Member

45 Posts

Posted - 2009-02-24 : 13:46:49
CANCEL_REASON - CHAR(02)
TRANSALATOR_DATA - CHAR(04)
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-24 : 13:59:52
what about Policy_Number?
Go to Top of Page

8022421
Starting Member

45 Posts

Posted - 2009-02-24 : 14:09:47
CHAR(03)
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-24 : 14:13:56
[code]

UPDATE MYTABLE
SET translator_data = Coalesce(NULLIF(CANCEL_REASON,''),'01')
WHERE POLICY_NUMBER = '324'[/code]
Go to Top of Page
   

- Advertisement -