Hi Guys, Im facing an issue in my application with xp_read_file. the procedure returns null incase of a Network path. My application is huge and we can not run this as a service or as another user or apply workarounds given above. Do we have any solution to this problem in Sybase 12 driver version or a better work around please? regards, Wasim

asked 07 Aug '12, 01:27

Wasim's gravatar image

accept rate: 0%

retagged 07 Aug '12, 04:46

Daz%20Liquid's gravatar image

Daz Liquid

I infer from your question that you are not running the database server as a service. As Justin noted, paths used by xp_read_file are relative to the user & machine where the server is running. If that is what you are trying to do and it is still not working, consider that it could also be an escaping issue:

xp_read_file( '\\server\network_share\foo.txt' )

has a carriage return in the middle of it and isn't actually a UNC name. The path will get translated to "\server[carriage-return]etwork_share\foo.txt" by the SQL parser.

permanent link

answered 07 Aug '12, 09:33

John%20Smirnios's gravatar image

John Smirnios
accept rate: 40%

edited 07 Aug '12, 09:34


...so the solution would be to escape all backslashes correctly (by doubling them...):

xp_read_file( '\\\\server\\network_share\\foo.txt' )
(07 Aug '12, 09:39) Volker Barth
Replies hidden

Or use a host variable.

(07 Aug '12, 12:07) John Smirnios

xp_read_file() is something done by the database engine (NOT the client application) - it has to operate with the user rights granted by the operating system to the user account that it is running under.

If you want the database engine to be able to access files on a network path, the user credentials that the database engine is running under, has to have read access to that path - nothing is going to be able to get round that.

The choices are either to:

  • grant READ rights on the network location to the user account the database engine is running under
  • run the database engine using an existing set of user credentials with sufficient rights to rea files in the network location

You don't say which operating system you are using on your database server, but if it's Windows (of any flavour) remember that the local system account has no network access at all by default.

UPDATE - I've just seen the other thread on this question, but it doesn't change what will be the basic problem here. The best thing is probably start with the simplest possible example of what you are trying to do - and work up from there.

permanent link

answered 07 Aug '12, 09:25

Justin%20Willey's gravatar image

Justin Willey
accept rate: 21%

edited 07 Aug '12, 09:32

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 07 Aug '12, 01:27

question was seen: 756 times

last updated: 07 Aug '12, 12:07