|
The following
samples with book publishers demonstrates the usage of COALESCE:
USE pubs
go
DECLARE @Publishers VARCHAR(4096)
SELECT @Publishers = COALESCE(@Publishers + ', ', '') + pub_name
FROM publishers
SELECT Publishers = @Publishers
GO
It will print:
McGraw-Hill, New Moon Books, Binnet & Hardley, Algodata Infosystems,
Five Lakes Publishing, amazon.com, Ramona Publishers, GGG&G,
Scootney Books, Lucerne Publishing, Double Day, Harper & Collins.
|