> Does anyone know how to traverse a list of prse a string
> in T-SQL inside a stored procedure?
> What I need to do i send a comma delimited list into a
> stored proc then loop over the list inserting each entry
> into a table.
> Any help would be appreciated.
> Thanks,
> Michael T. Tangorre
Yep...
DECLARE @list varchar(30);
DECLARE @element varchar(30);
DECLARE @d char(1);
DECLARE @x INT;
SET @d = ',';
SET @list = 'hello,world,out,there';
SET @list = @list + @d;
SET @x = charindex(@d,@list);
print @list;
WHILE (@x > 0) BEGIN
SET @element = left(@list,@x-1);
PRINT @element;
SET @list = substring(@list,@x+1,len(@list));
SET @x = charindex(@d,@list);
END
Replace PRINT for whatever you need to do with the individual element
and don't forget to add an extra delimiter to the end of the list as such:
SET @list = @list + @d;
s. isaac dealey 954-776-0046
new epoch http://www.turnkey.to
lead architect, tapestry cms http://products.turnkey.to
tapestry api is opensource http://www.turnkey.to/tapi
certified advanced coldfusion 5 developer
http://www.macromedia.com/v1/handlers/index.cfm?ID=21816
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4