问题描述
创建在SQL 9(2005)的存储的过程,并有自升级到SQL 10(2008)。此后,以下存储过程已停止工作,并抛出了上述错误:
Created a stored procedure in SQL 9 (2005) and have since upgraded to SQL 10 (2008). Since then, the following stored procedure has stopped working and thrown up the above error:
ALTER PROCEDURE [dbo].[GetModifiedPages]
@vPortalUID nvarchar(32) = ''
AS
BEGIN
-- Convert GUID to UI
DECLARE @nPortalUID AS uniqueidentifier
SET @nPortalUID = CAST(@vPortalUID AS uniqueidentifier)
中参数@vPortalUID通过包含:2A66057D-F4E5-4E2B-B2F1-38C51A96D385。我执行存储过程是这样的:
The passed in param @vPortalUID contains: 2A66057D-F4E5-4E2B-B2F1-38C51A96D385. I execute the stored proc like this:
EXEC GetModifiedPages '2A66057D-F4E5-4E2B-B2F1-38C51A96D385'
它倒下。我曾尝试转换以及。仍然没有喜悦。曾经也值与将在{}周围。我和编程如上手动删除它们。
It falls over. I have tried Convert aswell. Still no joy. Have also had the value going in with { } around it. I removed these programatically and manually as above.
如果你有兴趣我正在从ASP经典页SP,尽管这不应该影响这个作为上述code,采用SSMS运行。
If you are interested I am running the SP from an ASP Classic page, although that should not affect this as the above code was run using SSMS.
在此先感谢您的帮助。
詹姆斯
Thanks in advance for your help.James
推荐答案
这将失败:
DECLARE @vPortalUID NVARCHAR(32)
SET @vPortalUID='2A66057D-F4E5-4E2B-B2F1-38C51A96D385'
DECLARE @nPortalUID AS UNIQUEIDENTIFIER
SET @nPortalUID = CAST(@vPortalUID AS uniqueidentifier)
PRINT @nPortalUID
这个作品
DECLARE @vPortalUID NVARCHAR(36)
SET @vPortalUID='2A66057D-F4E5-4E2B-B2F1-38C51A96D385'
DECLARE @nPortalUID AS UNIQUEIDENTIFIER
SET @nPortalUID = CAST(@vPortalUID AS UNIQUEIDENTIFIER)
PRINT @nPortalUID
不同的是 NVARCHAR(36)
,您的输入参数是太小了!
the difference is NVARCHAR(36)
, your input parameter is too small!
这篇关于从字符串转换为uniqueidentifier时转换失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!