Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Load Data command

Author  Topic 

Moozzie
Starting Member

17 Posts

Posted - 2007-12-14 : 06:53:55
Hi foks!

In MYSQL I can insert a whole text/excel/csv file with the Load Data command. Can I do such a thing for MSSQL?

Thank you!

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-12-14 : 06:55:14
Yes. Read this: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=37980

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-14 : 07:21:03
quote:
Originally posted by Moozzie

Hi foks!

In MYSQL I can insert a whole text/excel/csv file with the Load Data command. Can I do such a thing for MSSQL?

Thank you!


Read about bcp or openrowset in sql server help file

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Moozzie
Starting Member

17 Posts

Posted - 2007-12-14 : 07:23:58
I think we have a misunderstanding here
The is the first 3 rows of the text file

1,9864327,email@email.com
2,2386647,email@email.com
3,4789182,email@email.com

And i want to insert those results in the database. But i don't want to do this:
INSERT INTO [table] SET (field,field,field) VALUES (value,value,value)
For each record.

In mYsql I can insert the data of the csv file and then he will insert all records/rows to the database

Can mSsql do that ??
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-14 : 07:25:19
quote:
Originally posted by Moozzie

I think we have a misunderstanding here
The is the first 3 rows of the text file

1,9864327,email@email.com
2,2386647,email@email.com
3,4789182,email@email.com

And i want to insert those results in the database. But i don't want to do this:
INSERT INTO [table] SET (field,field,field) VALUES (value,value,value)
For each record.

In mYsql I can insert the data of the csv file and then he will insert all records/rows to the database

Can mSsql do that ??


You need to read my previous reply

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Moozzie
Starting Member

17 Posts

Posted - 2007-12-14 : 07:30:03
@madhivanan
I did not see yours before i post a reply ;-)
I will read about bcp and openrowset
Go to Top of Page

Moozzie
Starting Member

17 Posts

Posted - 2007-12-14 : 07:42:07
Oke i see that my aplication (Aqua Data Studio) can import these csv files and i'm happy with that. But it must also be done by Batch, so is there a SQL command for wich can handle the import himself?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-14 : 08:06:37
Example from sql server help file
BULK INSERT Northwind.dbo.[Order Details]
FROM 'f:\orders\lineitem.tbl'
WITH
(
FIELDTERMINATOR = '|',
ROWTERMINATOR = '|\n'
)



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Moozzie
Starting Member

17 Posts

Posted - 2007-12-14 : 11:49:51
You dont know how much you helped me with this :D
Thanks !
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-15 : 01:18:31
quote:
Originally posted by Moozzie

You dont know how much you helped me with this :D
Thanks !


In fact, I know

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -