This SP is used for the create CSV values
like A,B,C,D,E
CREATE FUNCTION SEL_MAIL(@Email varchar(100))
RETURNS varchar(100)
AS
BEGIN
DECLARE @xyz VARCHAR(100)
declare @abc varchar(100)
set @abc=' '
declare selemail cursor for
select email from dataadi
open selemail
fetch NEXT from selemail into @xyz
WHILE @@Fetch_status = 0
begin
set @abc= @abc+ @xyz+','
FETCH NEXT FROM selemail INTO @xyz
END
CLOSE selemail
DEALLOCATE selemail
return @abc
END
--Sample table schema
Create table SchemaID([ID] smallint,SchemaID int NOT NULL)
--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
Thanks
helpondesk team
No comments:
Post a Comment