Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
How to import a UNIX data file
Old 06-03-2008, 07:32 PM How to import a UNIX data file
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
http://blogs.msdn.com/sqlserverstora...Data-File.aspx

This is a fantastic blog, that everyone doing much database work should look into. While reading about index fragmentation and disc based resource contention, I found this article. Knowing how common Linux web hosting is, and how much better SQL Server is than MySQL, I'm sure I'm not the only one who would love to analyze Apache logs in SQL.

Actually, I'm guessing most of us at least occasionally need to deal with data in files that were created on a different operating system. The step by step of how you go about that is going to be radically different, but the concept is the same.

Quote:
When bulk importing data, the data can come from any source including the files created in other operating systems like UNIX. Here are two ways that you can use to bulk import a data file created under UNIX.

·Without using a format file
You can use the following script to bulk load.

DECLARE @bulk_cmd varchar(1000)
SET @bulk_cmd = 'BULK INSERT AdventureWorks.Sales.SalesOrderDetail
FROM ''<drive>:\<path>\<filename>''
WITH (ROWTERMINATOR = '''+CHAR(10)+''')'
EXEC (@bulk_cmd)

However, the following will not work because '\n' automatically gets converted to '\r\n' since it's the typical EOF string for Windows text files. The reason that \n works like it does, because we want BCP commands from Unix world on Windows as well

bulk insert bcptest
from 'C:\unix\u.dat'
WITH (ROWTERMINATOR='\n')
·You can use explicit format file with the line terminator character as “\n”
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-04-2008, 12:39 AM Re: How to import a UNIX data file
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
I've done a MS SQL to MySQL migration one time. I used a tool called the MySQL Migration Toolkit, available here: http://www.mysql.com/products/tools/migration-toolkit/
The tool has very good logging feature, as well as script generation for the MySQL end of the transition, but will handle it all automatically if need be.
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Reply     « Reply to How to import a UNIX data file
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.66433 seconds with 12 queries