UPDATE PropertyInformationDump
SET RegistryAdd = COALESCE(NULLIF(b.OCAREOF, ''), b.OCAREOF + ', ','') +
COALESCE(NULLIF(b.O1STADD, ''), b.O1STADD + ', ','') +
COALESCE(NULLIF(b.O2NDADD, '') + b.O2NDADD + ', ','') +
COALESCE(b.OSTNAME + ', ','') + COALESCE(b.OCITYST + ' ','') +
COALESCE(NULLIF(b.OZIP, ''), b.OZIP,'')
FROM dbo.vw_BRT b
WHERE BRTNumber = b.PARCEL
GO
想要除去這些組合字符串前面的逗號。這裏是正在發生的事情的一個例子:通過Coalasce和NULLIF刪除引號括號?
, , 1350 SUSQUEHANNA AVE, PHILADELPHIA PA 19125
MICHAEL J CARLONE, 10050 ROOSEVELT BLVD, PHILADELPHIA PA 191163924
需要它總是看起來像:
1350 SUSQUEHANNA AVE, PHILADELPHIA PA 19125
或只是如何一個與OCAREOF填充:
MICHAEL J CARLONE, 10050 ROOSEVELT BLVD, PHILADELPHIA PA 191163924
我需要如果該字段爲空或爲空,請刪除這些逗號。顯然我做錯了!
你在什麼DBMS上?我不認爲在你的語法中你需要COALESCE,NULLIF和添加一個逗號應該全部處理它 – 2013-03-11 15:15:39
SQL Server 2005 – korrowan 2013-03-11 15:16:56