Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OPENROWSET BULK simple example, puzzling error

Status
Not open for further replies.

RRinTetons

IS-IT--Management
Jul 4, 2001
333
0
0
US
SQL Server 2005, 2008

Working from various web page examples of OPENROWSET I created two files on the server:

C:\RowSetWork\values.txt
C:\RowSetWork\format.fmt

values.txt looks like:

Code:
1     Data Item 1
2     Data Item 2
3     Data Item 3

format.fmt is:

Code:
9.0
2
1  SQLCHAR  0  10 "\t"        1  ID                SQL_Latin1_General_Cp437_BIN
2  SQLCHAR  0  40 "\r\n"      2  Description        SQL_Latin1_General_Cp437_BIN

I call:

Code:
SELECT a.* 
FROM OPENROWSET(BULK 'C:\RowSetWork\values.txt',
		FORMATFILE = 'C:\RowSetWork\format.fmt') AS a;

and get an error:

Code:
Msg 4862, Level 16, State 1, Line 1
Cannot bulk load because the file "C:\RowSetWork\format.fmt" could not be read. Operating system error code (null).

I can paste that file path into a command window and the file opens right up, ditto values.txt.

I'm stumped. That's about as simple as I can make it and it's not working.

????

-
Richard Ray
Jackson Hole Mountain Resort
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top