Separate Field

Last Post 06 Nov 2007 06:52 AM by nosepicker. 3 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
sgfubt321
New Member
New Member

--
06 Nov 2007 06:33 AM
I have data listed in a column in the following format:

215603/99399482/1/2321

How would I separate to have 4 columns that look like:

c1 c2 c3 c4
215603 99399482 1 2321

Thank you...
nosepicker
New Member
New Member

--
06 Nov 2007 06:52 AM
If you know for sure that you will only have a maximum of 4 elements to be separated, you can make use of the PARSENAME function:

declare @string varchar(50)
set @string = '215603/99399482/1/2321'

SELECT
PARSENAME(REPLACE(@string, '/', '.'), 4),
PARSENAME(REPLACE(@string, '/', '.'), 3),
PARSENAME(REPLACE(@string, '/', '.'), 2),
PARSENAME(REPLACE(@string, '/', '.'), 1)
sgfubt321
New Member
New Member

--
07 Nov 2007 02:08 AM
This worked great! Thank you very much.
nosepicker
New Member
New Member

--
08 Nov 2007 06:49 AM
You are not authorized to post a reply.

Acceptable Use Policy