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)
 Updating table with null fields

Author  Topic 

OldMySQLUser
Constraint Violating Yak Guru

301 Posts

Posted - 2009-07-15 : 07:01:31
I want to concantenate two fields and place the result in a temporary field and have been using:


USE Debt
GO
UPDATE Debtor
SET TempField = KeyInformation + ' ' + NextLegalAction


However, the KeyInformation field can contain a NULL, which creates a NULL in the TempField also.

How can I have the TempField contain the contents of the NextLegalAction field if the KeyInformation field contains a NULL please?

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-07-15 : 07:07:02
UPDATE Debtor
SET TempField = ISNULL(KeyInformation,'') + ' ' + ISNULL(NextLegalAction,'')
Go to Top of Page

OldMySQLUser
Constraint Violating Yak Guru

301 Posts

Posted - 2009-07-15 : 07:18:04
quote:
Originally posted by bklr

UPDATE Debtor
SET TempField = ISNULL(KeyInformation,'') + ' ' + ISNULL(NextLegalAction,'')




Aha! Many thanks for educating me.
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-07-15 : 07:18:58
quote:
Originally posted by OldMySQLUser

quote:
Originally posted by bklr

UPDATE Debtor
SET TempField = ISNULL(KeyInformation,'') + ' ' + ISNULL(NextLegalAction,'')




Aha! Many thanks for educating me.



welcome

u can use coalesce also in place of isnull
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-07-15 : 13:34:46
quote:
Originally posted by OldMySQLUser

quote:
Originally posted by bklr

UPDATE Debtor
SET TempField = ISNULL(KeyInformation+ ' ','') + ISNULL(NextLegalAction,'')




Aha! Many thanks for educating me.


slight modification to avoid the unecessary space in case of NULL
Go to Top of Page
   

- Advertisement -