tried creating and editing CSV files with data from SQL
on another thread i have tried BCP but it has had problems so tried another method.
I am copying a template CSV file, using Openrowset and then running a Batch file to remove the headers for import into another program
EXEC sp_configure 'show advanced option', '1';
RECONFIGURE;
EXEC sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE;
DECLARE @FILENAME AS VARCHAR(255)
SET @FILENAME = 'COPY /Y D:\pensions\pensions.csv /B D:\pensions\pensionsexport.csv'
EXEC sp_configure 'show advanced options', 1
RECONFIGURE
EXEC sp_configure 'xp_cmdshell', 1
RECONFIGURE
EXEC master..xp_cmdshell @FILENAME
INSERT INTO OPENROWSET('Microsoft.ACE.OLEDB.12.0','Text;Database=D:\pensions\;HDR=NO;FMT=Delimited','SELECT * FROM [pensionsexport.csv]')
SELECT company, address, postcode FROM tbl_ifa
EXEC master..xp_CMDShell 'D:\pensions\remove.bat'
The first two parts work fine but when i run the xp.CMSShell for the batch file i get access denied. Strangely the first part which also contains xpcmdshell works fine so why can it not work on the batch file which is in the same folder
on another thread i have tried BCP but it has had problems so tried another method.
I am copying a template CSV file, using Openrowset and then running a Batch file to remove the headers for import into another program
EXEC sp_configure 'show advanced option', '1';
RECONFIGURE;
EXEC sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE;
DECLARE @FILENAME AS VARCHAR(255)
SET @FILENAME = 'COPY /Y D:\pensions\pensions.csv /B D:\pensions\pensionsexport.csv'
EXEC sp_configure 'show advanced options', 1
RECONFIGURE
EXEC sp_configure 'xp_cmdshell', 1
RECONFIGURE
EXEC master..xp_cmdshell @FILENAME
INSERT INTO OPENROWSET('Microsoft.ACE.OLEDB.12.0','Text;Database=D:\pensions\;HDR=NO;FMT=Delimited','SELECT * FROM [pensionsexport.csv]')
SELECT company, address, postcode FROM tbl_ifa
EXEC master..xp_CMDShell 'D:\pensions\remove.bat'
The first two parts work fine but when i run the xp.CMSShell for the batch file i get access denied. Strangely the first part which also contains xpcmdshell works fine so why can it not work on the batch file which is in the same folder