2

My question is about this question asked before : How to create stored procedure in C#, then *save* it to SQL Server?

In every case in that question, how can I check, control or compile that sp? In this situation, I can create a sp that will not be compiled again from SQL server such as if table not exists?

Community
  • 1
  • 1
Mehmet Ince
  • 4,059
  • 12
  • 45
  • 65
  • 1
    I usually use SQL Server Management Studio (SSMS) which comes with SQL Server. I create my stored procedures in SSMS which has better error checking than if you do it in c#. You can save the stored procedures as a SSQL text file to reuse. Once the stored procedures are created you can then access then from c#. – jdweng Nov 23 '16 at 12:29

1 Answers1

2

You need to pass the error back to your program. Also, you cannot create same named procedures. You need to delete the old one first. Here's a list of ways with which you can do that.

Sql Server equivalent to Oracle's CREATE OR REPLACE VIEW

Pass this first, check for old procedure and delete it. Then create a new procedure.

Community
  • 1
  • 1
Prajwal
  • 3,930
  • 5
  • 24
  • 50
  • Check this question. Here, they need a error message and error code, which you can get from SqlCommand. I think you can implement one of these methods. http://stackoverflow.com/questions/7024109/how-can-i-get-an-error-message-that-happens-when-using-executenonquery – Prajwal Nov 23 '16 at 12:50