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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 csv file processing into database

Author  Topic 

vithaljs
Starting Member

12 Posts

Posted - 2010-10-08 : 01:51:49
hi!
how to process the csv file in an SQL SERVER 2008? what are commands to process or import??

vithal

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-08 : 02:01:30
You can use bcp, BULK INSERT, SSIS, OPENQUERY, or the import/export wizard. You've got lots of options. I prefer bcp as it's command line and quick to type in.

Here's a quick example:
bcp Db1.dbo.Tbl1 in C:\SomeFile.csv -t, -T -Sserver1 -c -r\r\n

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

vithaljs
Starting Member

12 Posts

Posted - 2010-10-08 : 02:08:48
thanks alot,
but how about using BULK INSERT? will it work properly?

vithal
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-08 : 02:11:41
Yes. It's in my post above as being one of the ones that'll work.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

vithaljs
Starting Member

12 Posts

Posted - 2010-10-08 : 02:15:14
ok,

will try it!

Thanks alot!!

vithal
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-10-08 : 07:11:55
quote:
Originally posted by vithaljs

thanks alot,
but how about using BULK INSERT? will it work properly?

vithal


Yes. Refer http://beyondrelational.com/blogs/madhivanan/archive/2010/03/17/bulk-insert-to-table-with-specific-columns.aspx

Madhivanan

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

vithaljs
Starting Member

12 Posts

Posted - 2010-10-08 : 07:53:37
Thanks a lot!

its working superbly!!;)

vithal
Go to Top of Page

vithaljs
Starting Member

12 Posts

Posted - 2010-10-08 : 08:05:25
hi..
is there any other method for processing CSV file other then the one which are mentioned above!?

vithal
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-08 : 13:33:06
Why do you need more methods?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -