2

The problem I have is that we can't use the xp_cmdshell in the productive envirement. We don't have the permission for it. But what else can I use instead of xp_cmdshell for creating a file on a different server?

SELECT @path = RTRIM(sys_value) FROM system_ZZDB WHERE sys_key = 'bisKey83'
SET @cmd = 'sqlcmd -SCHW20037619 -E -dzentraleDatenbank -s "" -Q "SET NOCOUNT ON; SELECT * FROM sync_BisKey ORDER BY per_nummer" -o "'
SET @cmd = @cmd + @path + '\exportzzdb.txt" -w 1000'
exec master..xp_cmdshell @cmd

This is the code I can't use in the future. What else can i do to create files directly from de DB server? We are limited in server rights

Thank you alot.

loonybin
  • 21
  • 2
  • 1
    In properly secured environment you can't do anything, at least from SQL side. You could create some cmd file for reading data from SQL server and writing into file and run it manually on server(or using task scheduler); this requires enough rights too, but these can be configured more precisely. – Arvo Jan 07 '14 at 12:41
  • Thanks a lot for your commend. is it possible to create an c# assembly who can create files? I have permissions to create Store Procedures and I can scedule them but I dont know if i have rights to create files from an assembly. – loonybin Jan 07 '14 at 12:55

1 Answers1

0

You could:

  • Create a SQL Job with a Task Step having a type of PowerShell or OS CmdExec
  • Use Windows Task Scheduler and batch files
cycoder
  • 26
  • 2