September 29, 2009 at 2:28 pm
I have table
select vcLoginHistory
from
ResultsHistories where id =11507
Return values at column = vcLoginHistory in one table.
2009-09-17 15:03:51.840622,2009-09-17 15:08:48.6269,2009-09-17 15:28:31.794258
I want to seperate out to 3 or more columns by the comma. Note this data is not fixe length. They some time 21 to 26 varchar. But they are seperate by comma. This table have more than 800,000 records.
Do you know the way to do in sql in 1 column to more columns ???
Thank you for help
September 29, 2009 at 3:04 pm
It sounds like what you're looking for is parsing the data, then pivoting it.
The data from this article will teach you how to parse it http://www.sqlservercentral.com/articles/T-SQL/62867/.
That will give you one row per value (which is actually the correct way to store that kind of data). To turn the rows into columns, you should look up Pivot and Unpivot in Books Online.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
October 1, 2009 at 9:52 am
Thank you
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply