What about making a user defined function that will return a table given a string...I stole this from somewhere on the net' ages ago so I can't give credit to whoever wrote it. It's very useful though.It returns a table of values from your string based on the the delimiter you specify.IF EXISTS ( SELECT * from dbo.sysobjects WHERE id = object_id(N'[dbo].[fn_Split]') AND xtype IN (N'FN', N'IF', N'TF') ) DROP FUNCTION [dbo].[fn_Split]GOCREATE FUNCTION fn_Split (@text VARCHAR(8000), @delimiter VARCHAR(20) = ' ') RETURNS @Strings TABLE ( position INT IDENTITY PRIMARY KEY , value VARCHAR(8000) )AS BEGIN DECLARE @index int SET @index = -1 WHILE (LEN(@text) > 0) BEGIN -- Find the first delimiter SET @index = CHARINDEX(@delimiter , @text) -- No delimiter left? -- Insert the remaining @text and break the loop IF (@index = 0) AND (LEN(@text) > 0) BEGIN INSERT INTO @Strings VALUES (@text) BREAK END -- Found a delimiter -- Insert left of the delimiter and truncate the @text IF (@index > 1) BEGIN INSERT INTO @Strings VALUES (LEFT(@text, @index - 1)) SET @text = RIGHT(@text, (LEN(@text) - @index)) END -- Delimiter is 1st position = no @text to insert ELSE SET @text = RIGHT(@text, (LEN(@text) - @index)) END RETURNENDGO
-------------Charlie