ShellExecute the SQLServer BCP Utility does not work with large lpParams
Hi all,
What I'm trying to do is the following:
(BCP Utility is a SQLserver program to import and export data to/from a SQLServer database).
ShellExecute(0, 'Open', PChar('<path>\bcp.exe'), PChar(<some big querry string>), PChar(''), SW_Hide);
The value of <some big querry string> is something like this:
"SELECT A.DVB_CODE as 'personeelsnummer', B.L12_K_VERKVAKURE as 'Urenverkocht', B.L12_K_AANKOOPVAK as 'Urengekocht', CONVERT(char(10), B.L12_begindatum, 120) as 'datum'
FROM
SOMEDATABASE_MS..PII_DIENSTVERBND A, SOMEDATABASE_MS..LCE_GROEP012 B
WHERE B.DVB_OBJECTID = A.DVB_OBJECTID_ORG AND A.DVB_BEGINDATUM < getdate() AND A.DVB_EINDDATUMTOT >= getdate() AND B. L12_EINDDATUMTOT = (SELECT MAX(L.L12_EINDDATUMTOT) FROM SOMEDATABASE_MS..LCE_GROEP012 L WHERE L.DVB_OBJECTID = B.DVB_OBJECTID GROUP BY L.DVB_OBJECTID) ORDER BY 1"
queryout "C:\Cafetaria.CSV" -c -t; -S<SOMASERVER> -U<SOMEUSER> -P<SOMEPASSWORD> -o"C:\Cafetaria.LOG"
So the Params are:
1 the query itself, inclosed by "
2 queryout with path and file
3 -c -t;
4 -S -U -P
5 -o path and name log file
First I make sure all linebrakes are removed.
When I run this in Delphi it wors fine, but when I change the Query part so it gets bigger I get error 5 (Access is denied). One of the queries I have to use is bigger.
As a test I copy pasted the where part in the above query and got the error.
Well you guess it. Has anyone any idea? The TShellExecute params are AnsiString and allowed to be up to 2 GB in size according to Delphi. My queries are not even close to that size (2.14 Kb).
Any help would be appreciated.
Bom dia/Greatings,
Jose
Hi all,
What I'm trying to do is the following:
(BCP Utility is a SQLserver program to import and export data to/from a SQLServer database).
ShellExecute(0, 'Open', PChar('<path>\bcp.exe'), PChar(<some big querry string>), PChar(''), SW_Hide);
The value of <some big querry string> is something like this:
"SELECT A.DVB_CODE as 'personeelsnummer', B.L12_K_VERKVAKURE as 'Urenverkocht', B.L12_K_AANKOOPVAK as 'Urengekocht', CONVERT(char(10), B.L12_begindatum, 120) as 'datum'
FROM
SOMEDATABASE_MS..PII_DIENSTVERBND A, SOMEDATABASE_MS..LCE_GROEP012 B
WHERE B.DVB_OBJECTID = A.DVB_OBJECTID_ORG AND A.DVB_BEGINDATUM < getdate() AND A.DVB_EINDDATUMTOT >= getdate() AND B. L12_EINDDATUMTOT = (SELECT MAX(L.L12_EINDDATUMTOT) FROM SOMEDATABASE_MS..LCE_GROEP012 L WHERE L.DVB_OBJECTID = B.DVB_OBJECTID GROUP BY L.DVB_OBJECTID) ORDER BY 1"
queryout "C:\Cafetaria.CSV" -c -t; -S<SOMASERVER> -U<SOMEUSER> -P<SOMEPASSWORD> -o"C:\Cafetaria.LOG"
So the Params are:
1 the query itself, inclosed by "
2 queryout with path and file
3 -c -t;
4 -S -U -P
5 -o path and name log file
First I make sure all linebrakes are removed.
When I run this in Delphi it wors fine, but when I change the Query part so it gets bigger I get error 5 (Access is denied). One of the queries I have to use is bigger.
As a test I copy pasted the where part in the above query and got the error.
Well you guess it. Has anyone any idea? The TShellExecute params are AnsiString and allowed to be up to 2 GB in size according to Delphi. My queries are not even close to that size (2.14 Kb).
Any help would be appreciated.
Bom dia/Greatings,
Jose