Click here to monitor SSC
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
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 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
SSCrazy
SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)

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

----------------------------------------------
Msg 8134, Level 16, State 1, Line 1
Divide by zero error encountered.
andrewalex.r
andrewalex.r
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 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
SSCrazy Eights
SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)

Group: General Forum Members
Points: 8264 Visits: 19441
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
Grasshopper
Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)

Group: General Forum Members
Points: 22 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