0

I am making an application, I would like to be able to get a script to put data into the database, but i was wondering can i get SQL to Launch a C# application to get information from the web and return that into the database without having to interact with the SQL database.

Realistically I would like the operation to run like so:

Query -> Launch c# -> input the data to DB

but i would like this all to work from the initial procedure, is something like this possible?

Todd Owen
  • 97
  • 1
  • 9
  • Does this answer your question? [How to run a program from SQL?](https://stackoverflow.com/questions/1162663/how-to-run-a-program-from-sql) – DudeWhoWantsToLearn Jan 09 '20 at 08:02
  • 8
    DBAs everywhere will genuinely hate you if you do this... in almost any scenario, the flow should be "C# fetches / formats data from external source -> C# invokes SQL -> SQL stores (or whatever) the data". There *is* a capability to run .NET directly inside SQL Server, but : that is *also* no longer recommended, and is disabled by default on new versions, IIRC – Marc Gravell Jan 09 '20 at 08:04
  • Look at Sql clr integration https://learn.microsoft.com/en-us/sql/relational-databases/user-defined-functions/create-clr-functions?view=sql-server-ver15 – Serg Jan 09 '20 at 08:13

1 Answers1

1

It it not favoured practice but you can use the below stored procedure to call a C# executable. Some times it is unavoidable if you are constrained.

xp_cmdshell { 'command_string' } [ , no_output ]  

You can find the documentation here

Murray Foxcroft
  • 12,785
  • 7
  • 58
  • 86