I have a stored proc .sql file on my system. I want to be able to move this file into database as a sp from C# code.
i could open the file, read it in as a string, and execute it but I feel like there should be a better way.
I have a stored proc .sql file on my system. I want to be able to move this file into database as a sp from C# code.
i could open the file, read it in as a string, and execute it but I feel like there should be a better way.
Are you talking about having the stored procedure reside on the database instead of a string query in your C# code?
I may be way off base but your question isn't very clear...
Have you look into the TSQL command CREATE PROCEDURE?
It is possible to use the command line tools for whatever database server you are using to create the stored procedures. Executing the exe from C# with the correct parameters.
They will often accept the file name as a parameter, so you don't need to load the sql in as a string.
Don't know if that's what you are after, but it should work.