Click here to Skip to main content
15,906,292 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I am facing an issue while using SET PARSEONLY ON/OFF.

I hv created a SP which checks if a query passed to it is correct or not.
The SP executes fine on SQL Server 2008 but gives an error "A severe error occurred on the current command. The results, if any, should be discarded." on Sql Server 2005 .

The SP is :

SQL
CReate PROCEDURE parsetest(@str varchar(8000))
AS
begin
DECLARE @parseonoff AS VARCHAR(50)
BEGIN try

    --PRINT @str
    SET @str = 'SET PARSEONLY ON; ' + @str
    EXEC (@str)
    set @parseonoff = 'SET PARSEONLY OFF; '
    exec (@parseonoff + 'Select 1')

--  FROM dbo.Rostering
END TRY
BEGIN catch
    set @parseonoff = 'SET PARSEONLY OFF; '
    exec (@parseonoff + 'Select 0')
    --SET PARSEONLY off
END CATCH
END



Test Case 1:
SQL
DECLARE @str VARCHAR(1111)
--DECLARE @a INT
SET @str = 'SELECT 1'
--SET PARSEONLY ON
EXEC parsetest @str


Test Case 2:
SQL
DECLARE @str VARCHAR(1111)
--DECLARE @a INT
SET @str = 'SELECT bbb(1)'
--SET PARSEONLY ON
EXEC parsetest @str



Any help would be much appreciated .

Regards ,
Gopal
Posted

1 solution

check this out:

http://support.microsoft.com/kb/910416[^]

hope it helps :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900