0

I am trying to pass large html from ms sql to exe file by:

EXEC master..xp_CMDShell 'c:\path\index.exe' --body="<div style="font-family: Lato;""

This html can be very large more than 8k characters which I understand is the limit (win server 2008).
That is first problem and second is that when I try to pass html as argument from sql it always strip quotations.
Any suggestion how can I without problem pass any html to exe via sql command?

1110
  • 7,829
  • 55
  • 176
  • 334
  • Don't use `xp_cmdshell`? What are you actually trying to achieve here? – Thom A Mar 19 '20 at 13:34
  • We are moving from sp_senddbmail as we need to use oauth2 so we created exe file to send mails but from db we need to pass html content to send. But I was not aware of limitations. – 1110 Mar 19 '20 at 13:49
  • Perhaps you'd be better off asking about how to implement `oauth2` with SQL Server and `sp_send_dbmail`. Certainly using `xp_cmdshell` is the wrong path here. Alternatively, perhaps you should be using an application to read the data from the database. – Thom A Mar 19 '20 at 13:54
  • Yes reading from db is last option as that would lead to some bigger changes so trying to avoid for now. Is it possible to use oauth2 with sp_senddbmail? – 1110 Mar 19 '20 at 13:56
  • I personally don't know, but that doesn't mean it can't be. The question may be better suited to [dba.se], depending how you word it though. – Thom A Mar 19 '20 at 13:57
  • And perhaps the real problem is that you are trying to use sql server as some sort of email service in a fashion for which it is not well suited. Regardless, there are (and will likely always be) limits to the size of the command line buffer. Create a file and pass the file name? Pass the key to a particular row? Move the logic OUT of the database engine? – SMor Mar 19 '20 at 14:12

0 Answers0