mercredi 8 juin 2016

SQL COALESCE modification

I have below code

SELECT @email = COALESCE(@email + ', ', '') + Email
FROM dbo.FTX_ALERTUSER WITH (NOLOCK)
WHERE AlertID = 9017 AND Email IS NOT NULL
--SELECT @email
--jlee_20160106b fixed bug from 20151028 change where Vendoremail not included.
SELECT @email2 = VENDOREMAIL FROM FTX_NCMR_VENDOR_REQUIREMENT WITH(NOLOCK) where VENDORCODE = @param1  and BU = @param2
SELECT @email = @email + ',' + ISNULL(@email2,''' ''')

which is creating string

[ftx_alert_list] 'updateLastRunDT','9017','FTX-Software, Karthik@XYZ.com, ray@XYZ.com, tony@XYZ.com, yen@XYZ.com,' '','FTX_F20160607004'

I want to correct this string like

exec [ftx_alert_list] 'updateLastRunDT','9017','FTX-Software, Karthik@XYZ.com, ray@XYZ.com, tony@XYZ.com, yen@XYZ.com','','FTX_F20160607004'`

The only difference is ,' '', i want ','', after yen@XYZ.com.

Please help.

Aucun commentaire:

Enregistrer un commentaire