How to execute a c# code within an SQL procedure?

Viewed 68

I had a project in SSIS that I now want to run just by using T-SQL. Basically I have a datasource where I download csv files everyday into a directory. I have a full c# code that does exactly that and it runs perfectly when embedded in SSIS. How do I execute that code within my stored procedure? In case it's important, I use sql server 2017. Thank you!

1 Answers

EXECUTE master..xp_cmdshell 'exe location' will do what you need, it will run a cmd shell command, so you can just point it at the .exe of your c# code

DECLARE @Cmd nvarchar(500)
SET @Cmd = '"C:\program.exe"'
EXECUTE master..xp_cmdshell @Cmd
Related