I am running on SQL server on my local PC . I am singed onto the PC using a network user.
This probelm happens if the SQL server service runs as either Local system or network service.
In the server management studio if I go to a query window and enter
Declare @result int
exec xp_fileexist 'C:PlayWarrenty.txt' , @result output
it works fine and finds the file.
If I move it into a stored procedure something like.
ALTER PROCEDURE [dbo].[FileExistsCheck]
DECLARE @fe int
EXEC master.dbo.xp_fileexist @file , @fe OUTPUT
and execute it like this from an SQL Query window
DECLARE @RC int
EXECUTE @RC = [dbo].[FileExistsCheck] 'C:PlayWarrenty.txt'
Msg 22027, Level 15, State 1, Line 0
Usage: EXECUTE xp_fileexist <filename> [, <file_exists INT> OUTPUT]
The 'FileExistsCheck' procedure attempted to return a status of NULL, which is not allowed. A status of 0 will be returned instead.
Free Guide: Managing storage for virtual environments
Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!