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

Was it helpful?

Solution 2

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.

OTHER TIPS

Take a look Here and Here. Those links might help you to get through it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top