We need to make use of Coalesce function to get the result set as comma separated values.
--Sample table schema CREATE TABLE SchemaID ( [ID] smallint, SchemaID int NOT NULL ) go
--Dummy insert statements Insert into SchemaID values (1,12) Insert into SchemaID values (1,13) Insert into SchemaID values (1,14)
Insert into SchemaID values (2,15) Insert into SchemaID values (2,16) Insert into SchemaID values (2,17) Insert into SchemaID values (2,18)
--Solution DECLARE @ID varchar(100)
SELECT @iD=COALESCE(@ID + ', ', '') + CAST(SchemaID AS varchar(5)) FROM SchemaID WHERE [ID] = 1
SELECT @ID
|
No responses found. Be the first to respond and make money from revenue sharing program.
|