0

BCP shell Command is not writing file in my server. and I have given all the rights to the folder path. But Same command is working fine in another server. is there any server or SQL Server permission required for this?? please suggest

select @cmd = ' bcp "select edi_text from scmdb..swo_edihold_file_data_tmp order by sequenceno" queryout ' + @filename + ' -c -r\n -t"|"  -S' + @servername +' -Uusername -Ppassword' 

exec master..xp_cmdshell @cmd,no_output
jarlh
  • 42,561
  • 8
  • 45
  • 63
  • Have a look at https://stackoverflow.com/questions/2016669/getting-execute-permission-to-xp-cmdshell it may help – indofraiser Jun 17 '19 at 10:09
  • 2
    what does error log says ? – Ven Jun 17 '19 at 10:23
  • its executed successfully. But, file not generating in mentioned path – Padmasri Raman Jun 17 '19 at 10:43
  • can you execute the query in second server ( where file not creating) and let us know the results please – Ven Jun 17 '19 at 12:23
  • its run properly. No error is Coming. and file is not creating – Padmasri Raman Jun 17 '19 at 12:49
  • It's been a long time since i've used xp_cmdshell (it's a security risk and should be disabled), but if I recall correctly, SQL Server doesn't care what happens to the shell command itself. xp_cmdshell will only report errors in handing of the command to the shell. So, it may LOOK like it didn't fail, but you most likely are getting an error that you just cannot see. As Ven stated, you need to trap errors. Either use -e (this will show errors with data on a load, so wont help much here). Next is to redirect output from the shell command to a file with the ">" operator. – jamie Jun 17 '19 at 18:29

0 Answers0