You execute an action statement against a database by calling ExecuteNonQuery on a SqlCommand. If you want to actually execute the script file rather than just the SQL code it contains then you can use Process.Start to run SQLCMD. I'm not sure of the exact commandline but you can look that up.
How to insert stored procedure into SQL Server from console application in C#?
-
19-10-2022 - |
Question
I want to write or insert stored procedure into a SQL Server database from a console application in C#. How can I do this?
I have a stored procedure in a SQL script file and it's in one folder in my console application folder. Now how can I insert or write that stored procedure in SQL Server when my console app is running?
Regards
Solution 2
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow