I’m having some troubles with the mapping of an sql server stored procedure into a table. I would like to have some clarifications about this matter. Here attached you’ll find a test procedure.
If the input is null, it generates an exception, otherwise it inserts a row in a log table ad returns the resultset.
The import of sp doesn’t work and generate an error (2 times).
I also attached the profile of the SQL server
The procedure has been executed in a regular way for 2 times!
The errors occured from the exception that shows up when the procedure runs with null. So I am assuming that the procedure has not simply been imported but it runs twice.
For this reason, I’ve modified the store procedure by removing the control, in order to have the procedure running until the end.
Here it shows that everything worked out well. The import worked.
Since everything was working well, what I did was to check the log table inside the store procedure (that table was emptied before).
The result is that in the table you can find a row inserted by the import of the store procedure that I’ve just run.
For this reason I am worried because i’m sure that if I had more complex work to do or if I had some delete, the import would modify or lose data.
The profiler of the sql server shows that the procedure run just once.
If I modify the procedure (as I mentioned and showed in proc1) by putting insert before the exception, I will see two insert into log table
So Iwhat i’m asking is why does the procedure run during the import? And if this supposition is correct, how do I need to proceed? What shall i do to be able to import this type of procedure without errors?