SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


I need the code part for splitting the row into different columns?


I need the code part for splitting the row into different columns?

Author
Message
andrewalex.r
andrewalex.r
SSC Rookie
SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)

Group: General Forum Members
Points: 44 Visits: 29
1 : 7 ; 9 : 21:Task Completed:2013-04-08, 1 : 8 ; 10 : 22:Good:2013-04-08, 1 : 9 ; 8 : 19:Not Bad:2013-04-08, 1 : 10 ; 7 : 18:Bad:2013-04-08, 1 : 11 ; 9 : 21:Excellent:2013-04-08, 1 : 12 ; 7 : 24:Task Completed:2013-04-08, 1 : 13 ; 8 : 23:In Progress:2013-04-08

--------------------------------------------------------------------
I need the above values as the below table format,pls help me

------------------------------------------------------------------
Company_ID Employee_ID In_Time Out_Time Remarks Entry_Date
1 7 9 21 Task Completed 2013-04-08
1 8 10 22 Good 2013-04-08
1 9 8 19 Not Bad 2013-04-08
1 10 7 18 Bad 2013-04-08
1 11 9 21 Excellent 2013-04-08
1 12 7 24 Task Completed 2013-04-08
1 13 8 23 In Progress 2013-04-08
Henrico Bekker
Henrico Bekker
SSCertifiable
SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)

Group: General Forum Members
Points: 7620 Visits: 5016
looks like the results from a csv/txt file?
Tried using SSIS and selecting "First column is headers", delimit it properly to assign columns?

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This thing is addressing problems that dont exist. Its solution-ism at its worst. We are dumbing down machines that are inherently superior. - Gilfoyle
andrewalex.r
andrewalex.r
SSC Rookie
SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)

Group: General Forum Members
Points: 44 Visits: 29
Company_ID Employee_ID In_Time Out_Time Remarks Entry_Date
1 7 9 21 Task Completed 2013-04-08
1 8 10 22 Good 2013-04-08
1 9 8 19 Not Bad 2013-04-08
1 10 7 18 Bad 2013-04-08
1 11 9 21 Excellent 2013-04-08
1 12 7 24 Task Completed 2013-04-08
1 13 8 23 In Progress 2013-04-08
Phil Parkin
Phil Parkin
SSC Guru
SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)

Group: General Forum Members
Points: 52516 Visits: 21180
andrewalex.r (4/8/2013)
Company_ID Employee_ID In_Time Out_Time Remarks Entry_Date
1 7 9 21 Task Completed 2013-04-08
1 8 10 22 Good 2013-04-08
1 9 8 19 Not Bad 2013-04-08
1 10 7 18 Bad 2013-04-08
1 11 9 21 Excellent 2013-04-08
1 12 7 24 Task Completed 2013-04-08
1 13 8 23 In Progress 2013-04-08


Are you saying that the first post shows a single row (in a text file?) and that you want to create a text file that looks like this?


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
ronang
ronang
Valued Member
Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)

Group: General Forum Members
Points: 54 Visits: 136
Hi

It seems like you need to clean up your delimiters and there are generally two:
1. Row delimiter
2. Column delimiters

Your row delimiter seems to be a comma (,) but your column delimiters seem to be mixed between a colon (Smile and a semi colon (Wink which I suspect is why you're having an issue attempting to split this into a proper columns and records. If this is your issue then:
1. Standardise all column delimiters by using a text editing programme (Notepad etc). I usually use the Replace function to perform this quickly. My suggestion is to use pipe (|) delimiters.
2. Standardise your row delimiters.
3. Attempt to import data using the SQL Import/Export wizard to import to target table
4. If 3. fails then use BCP to perform the Import into a new SQL table (This rarely fails)
5. Using the Insert Into...Select from move the data from the new SQL table to the original target table.
6. Step 5 might require some data transformation.

I generally find it easier to work with data once the data is in SQL Server.

I hope this helped.
Regards,
Ronan
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search