SET PARSEONLY ON/OFF在2008年工作正常,但在2005年失败 [英] SET PARSEONLY ON/OFF working fine on 2008 but fails on 2005

查看:141
本文介绍了SET PARSEONLY ON/OFF在2008年工作正常,但在2005年失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

使用SET PARSEONLY ON/OFF时遇到问题.

我创建了一个SP,用于检查传递给它的查询是否正确.
SP在SQL Server 2008上可以正常执行,但会出现错误当前命令发生严重错误.如果有结果,应将其丢弃."在Sql Server 2005上.

SP是:

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 :

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




测试案例1:




Test Case 1:

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



测试案例2:



Test Case 2:

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




任何帮助将不胜感激.

问候,
Gopal




Any help would be much appreciated .

Regards ,
Gopal

推荐答案

检查一下:

http://support.microsoft.com/kb/910416 [
check this out:

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

hope it helps :)


这篇关于SET PARSEONLY ON/OFF在2008年工作正常,但在2005年失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆