December 27, 2006 at 9:21 am
Example
Col1 = FIN - TIN - LIN - BIN
Need to take col1 and make 4 columns out of it.
col1 = FIN
col2 = TIN
col3 = LIN
col4 = BIN
Isn't this charindex or something like that?
December 27, 2006 at 9:30 am
Check this out:
http://www.sqlservercentral.com/columnists/sjones/20010424135929_1.asp
Charindex or patindex will work.
December 27, 2006 at 1:44 pm
IF you will always have 4 columns, then this will work nicely...
DECLARE @TestText VARCHAR(100)
SET @TestText = 'FIN - TIN - LIN - BIN'
SELECT PARSENAME(REPLACE(@TestText,' - ','.'),4) AS FirstCol,
PARSENAME(REPLACE(@TestText,' - ','.'),3) AS SecondCol,
PARSENAME(REPLACE(@TestText,' - ','.'),2) AS ThirdCol,
PARSENAME(REPLACE(@TestText,' - ','.'),1) AS FourthCol
IF you have a variable number of columns or more than 4 columns, we'll have to resort to other measures... let us know, please.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply