문제

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

도움이 되었습니까?

해결책 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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top