这是我的代码:
USE [MRC]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[Lookup_APN_GUID]
(
-- Add the parameters for the function here
@PN_Key int
)
RETURNS UNIQUEIDENTIFIER
AS
BEGIN
-- Declare the return variable here
DECLARE @PN_GUID UNIQUEIDENTIFIER
SELECT @PN_GUID = PNID
FROM PNEB
WHERE PNID = (@PN_Key)
RETURN @PN_GUID
END
我收到以下错误消息:
Msg 206,Level 16,State 2 过程Lookup_PN_GUID,操作数类型冲突:int与uniqueidentifier不兼容
我尝试在标量变量声明上将int
切换为nvarchar
。仍然收到错误消息。 uniqueidentifier
是int
。我很茫然。
任何想法?
答案 0 :(得分:0)
USE [MRC]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[Lookup_APN_GUID]
(
-- Add the parameters for the function here
@PN_Key int
)
RETURNS UNIQUEIDENTIFIER
AS
BEGIN
-- Declare the return variable here
DECLARE @PN_GUID UNIQUEIDENTIFIER
SELECT @PN_GUID = PNID
FROM PNEB
**WHERE APNID = (@PN_Key)**
RETURN @PN_GUID
END