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 |
|
Bex
Aged Yak Warrior
580 Posts |
Posted - 2009-03-25 : 06:05:38
|
Hi thereI am trying to write a query to BCP data into a table from a data file. I have the following code:bcp sainsburys.crdm.Header_20070530 in "SELECT * FROM OPENROWSET(BULK 'D:\crdm.Header_20070530.dat')" -T -c -E But when I execute, I get the error:Error = [Microsoft][sql Native Client] Unable to open BCP host data-fileTHe file exists, and the path is correct.Any ideas?ThanksHearty head pats |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-03-25 : 06:07:06
|
BCP is NOT a T-SQL command. It is a MS-DOS application. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-03-25 : 06:12:51
|
| Make sure the file exists in the Server's directoryMadhivananFailing to plan is Planning to fail |
 |
|
|
Bex
Aged Yak Warrior
580 Posts |
Posted - 2009-03-25 : 06:21:59
|
| Hi madhivanan and PesoThanks for your replies. As Peso pointed out, BCP utility is command line code, therefore, debugging SQL is made difficult (silly me). So I removed the TSQL statement, and ran it in Management Studio:"SELECT * FROM OPENROWSET(BULK 'D:\crdm.Header_20070530.dat')"I'm missing a format file and an alias. So I'm debugging in management studio, and once I am sure it is all correct, I shall then (and only then) put it in the BAT file.Hearty head pats |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-03-25 : 07:21:33
|
SELECT * FROM OPENROWSET(BULK 'D:\crdm.Header_20070530.dat') as f E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|
|
|