views:

14

answers:

1

I am getting the following error

Can't Execute Stored Procedure::procedureName A severe error occurred on the current command. The results, if any, should be discarded.

when i am executing a stored procedure,which contains only select statements. How can i solve it?

Thanks ShaBeg

A: 

Some people report that setting NOCOUNT ON solves this issue...

CREATE PROCEDURE MyStoredProcedure AS
SET NOCOUNT ON
SELECT * FROM MyTable
GO

If this doesn't help, please can you confirm...

  1. If the select statement goes outside of the database boundary? i.e. you SELECT from multiple databases or cause an interaction with the file system outside of the database

  2. Are you using a temp table in the stored procedure?

In addition, what happens when you run the stored procedure directly in SQL Server?

Sohnee
This is helps in situations where you have more than one select statements within the same procedure. You have to do SET NOCOUNT OFF before the select statement that is returning the actual result.
Yves M.