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.
Author |
Topic |
KilpAr
Yak Posting Veteran
80 Posts |
Posted - 2012-05-24 : 02:28:25
|
I would need to insert with VBA code a lot of rows into a table. I have a local tab-separated text file (C:\MyFile.txt) that I print from Excel and would need to upload the data in it into my SQL server table "MyTable". I tried with:BULK Insert MyTable FROM 'C:\MyFile.txt' WITH(FIELDTERMINATOR = '\t',ROWTERMINATOR = '\n')but it insists c:\MyFile.txt doesn't exist (I'm sure it does).How am I supposed to refer to c:\MyFile.txt? With MySQL this worked easily using LOAD INFILE. |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-05-24 : 02:50:34
|
The C:\MyFile.txt refers to the C: Drive on the Server where MS SQL Server is. Not your local drive. KH[spoiler]Time is always against us[/spoiler] |
 |
|
KilpAr
Yak Posting Veteran
80 Posts |
Posted - 2012-05-24 : 03:03:20
|
quote: Originally posted by khtan The C:\MyFile.txt refers to the C: Drive on the Server where MS SQL Server is. Not your local drive.
Any way to make it refer to my local drive? Or is there any other options? I would prefer not to make hundreds of individual "INSERT INTO"-statements, but is that the only option? |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-05-24 : 03:07:45
|
1. copy the file to the serveror2. reference it using UNC Path \\computername\..... KH[spoiler]Time is always against us[/spoiler] |
 |
|
KilpAr
Yak Posting Veteran
80 Posts |
Posted - 2012-05-24 : 03:40:41
|
Got it to work by copying it to the server and reading from there.Thanks! |
 |
|
|
|
|