Pergunta

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

Foi útil?

Solução 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.

Outras dicas

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top