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 2005 Forums
 SSIS and Import/Export (2005)
 import csv file to table

Author  Topic 

a.ashabi
Posting Yak Master

117 Posts

Posted - 2007-11-07 : 15:30:46
Hi.I would like to import the pprice.csv to table test3 on test database.
I've run this query:

BULK INSERT test..test3 FROM 'c:\pprice.csv'
WITH (
FIRSTROW = 2,
MAXERRORS = 0,
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\t\n'
)


It has no error.but 0 rows effected.it means doesnt work correct.
what should I do?
thanks.
Amen

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-11-07 : 15:36:55
Does c:\pprice.csv exist on the database server or just on your client machine?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-11-07 : 16:05:10
moved from script library

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

a.ashabi
Posting Yak Master

117 Posts

Posted - 2007-11-07 : 16:15:59
The csv file is not on the database server.it's on the c drive on the server machine.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-11-07 : 16:21:47
That's the problem then. BULK INSERT runs from the perspective of the database server. So your path and file must be one that the database server understands. If it's a remote file, then you must use a UNC path or mapped network drive.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

a.ashabi
Posting Yak Master

117 Posts

Posted - 2007-11-11 : 13:39:29
thank u Tara.u are a big help.
Go to Top of Page
   

- Advertisement -