Continuing my series on how same things can be done differently in SQL Server and MySQL, in this post, we will see how bulk insert can be done in SQL Server vs MySQL.
We often need to import data from a text file to the server. Consider that the file D:\test.txt has data for three columns and you want to import this data into a table
In SQL Server we can use the BULK INSERT command
In MySQL we can user Load Data Command
load data local infile 'D:/test.txt' into table test
fields escaped by '\\'
terminated by '\,'
lines terminated by '\n'
Here both of them consider comma as a field separator and new line as the line separator
Note : By Default SQL Server looks for the existence of the file in Server's directory. In MySQL, we need to specify keyword local to instruct that file is available in the local system
Did you like this post?
|subscribe via rss||subscribe via e-mail|
|print this post||follow me on twitter|