xp_fileexist SP does not run in TMSStoredProc

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Posts: 1
Joined: Tue 30 Sep 2008 10:56

xp_fileexist SP does not run in TMSStoredProc

Post by DelphiDev » Tue 30 Sep 2008 11:24


Why does TMSQuery able to run this SP and TMSStoredProc does not ?
Is TMSStoredProc disabled to run extended stored procs or is it a bug ?

I tried with MSSQL 2000, MSSQL 2005 and the result is the same.


// xp_fileexist calling with TMSStoredProc is NOT working.
// Errormessage:
// "Usage: EXECUTE xp_fileexist [, OUTPUT]"

MSStoredProc1.ParamCheck := False;
MSStoredProc1.StoredProcName := 'master..xp_fileexist';

MSStoredProc1.ParamByName('filename').AsString := 'c:\autoexec.bat';

MSStoredProc1.ParamByName('file_exists').AsInteger := 0;


// xp_fileexist calling with TMSQuery is working.

MSQuery1.ParamCheck := True;
MSQuery1.SQL.Text := 'EXEC master..xp_fileexist :filename, :file_exists OUTPUT';

MSQuery1.ParamByName('filename').ParamType := ptInput;
MSQuery1.ParamByName('filename').AsString := 'c:\autoexec.bat';
MSQuery1.ParamByName('file_exists').ParamType := ptOutput;
MSQuery1.ParamByName('file_exists').AsInteger := 0;

ShowMessage('MSQuery: '+MSQuery1.ParamByName('file_exists').AsString);

Devart Team
Posts: 2888
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 02 Oct 2008 09:01

The problem is that xp_fileexist is System Extended Stored Procedure and for its execution SQL Server requires usage of EXEC statememt, but the TMSStoredProc component uses CALL statememt for stored procedure execution. Therefore you should use TMSQuery for executing this procedure.

Post Reply