>I have made a SP that takes a string does some replacements to create a pretty comma delimited string. Cuurently I have a single field table, what I need is to get the odd records to be col 1 and even to be col 2. If there is a better way to do it I am open to any ideas. I have included the very simple source here:
>This is my 4th SP, be kind;
>
>CREATE PROC CsvToRSw (
> @CSVstring varchar(500)
>)
>as
>
> Begin
> DECLARE @ExecuteString varchar(8000)
> DECLARE @WorkString varchar(8000)
>
> SELECT @ExecuteString = 'Select ''' + REPLACE((SELECT REPLACE((SELECT REPLACE((SELECT REPLACE(@CSVstring, "?","")), "=",",")) , "&",",") ), ",", ''' UNION ALL Select ''' )+''''
>
>
> EXECUTE (@ExecuteString)
> RETURN @@error
>End
>GO
>
>is there a line continuation char for SPs?
>
>My humble thanks in advance,
Good start Joe, with several ammendments. You don't need a continuation character. Also, you don't need the SELECTs on the right side of the statement and you don't need the UNION. Try this:
SET @ExecuteString = 'SELECT ' + REPLACE(REPLACE(REPLACE('?=&', '?',''), '=',',') , '&',',')
Carl