October 22, 2001 at 1:13 pm
in a function,
I need to take the results of a select statement and make it one comma dilimeted string. Any help would be appreciated!
October 22, 2001 at 2:21 pm
October 22, 2001 at 2:32 pm
I tried that and I get this error,
Error 444: select statements within A function cannot return data to a client.
or something like that.
is your example with a UDF or a Stored Procedure?
this is exactly what I have:
with the select statement returning multiple nvarchars.
CREATE function Get_Pop(@pop_group int)
Returns nvarchar(100)
Begin
declare @r varchar( 1000)
select @r = ''
select @r = rtrim(@r) + name ',' from SM_Servers,SM_group_Link where (SM_group_Link.group_name = @pop_group) and (SM_servers.ID = SM_Group_Link.group_item)
select substring( @r, 1, len( @r) - 1)
Return (@r)
End
October 22, 2001 at 3:48 pm
The probklem is your last line. This is returning a value, not removing the last ,.
Is should read:
select @r = substring( ...
Steve Jones
October 22, 2001 at 5:01 pm
Doesnt the function have to return a value!
or inlined within another statement will it automatically do that, sort of like the function getdate()?
October 23, 2001 at 7:54 am
CREATE function Get_Pop(@pop_group int)
Returns nvarchar(100)
BEGIN
declare @r nvarchar(1000)
select @r = ''
select @r = rtrim(@r) + name + "," from SM_Servers,SM_group_Link where (SM_group_Link.group_name = @pop_group) and (SM_servers.ID = SM_Group_Link.group_item)
select substring( @r, 1, len( @r) - 1)
END
I still get Error 444 with this
October 23, 2001 at 7:59 am
Actually it worked I had the last line wrong
this is what I have
CREATE function Get_Pop(@pop_group int)
Returns nvarchar(1000)
BEGIN
declare @r nvarchar(1000)
select @r = ''
select @r = rtrim(@r) + type from SM_Servers,SM_group_Link where (SM_group_Link.group_name = @pop_group) and (SM_servers.ID = SM_Group_Link.group_item)
select @r = substring(@r, 1, len(@r) - 1)
RETURN(@r)
END
yet it returns a numeric value??????
October 23, 2001 at 7:59 am
Damn Never mind, i screewed up again!
thank you so much for your help
you saved my ass!
October 29, 2001 at 3:55 pm
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply