0

大家好,我已经写了这个存储过程,但是里面有一个错误,上面写着

无法在 nvarchar 上调用方法

T-SQL 代码:

ALTER PROCEDURE dbo.User_Announcement_Create
        @Announcement nvarchar(250),
        @UserName nvarchar(256)
AS
BEGIN
    DECLARE @NewAnnouncement nvarchar(250)
    SELECT @NewAnnouncement = NULL

    IF( @UserName.dbo.Announcements IS NULL )
       ( SELECT UserName FROM dbo.aspnet_Users
         WHERE @UserName = UserName ) 
       RETURN -1
END

DECLARE @CreateAnnouncement bit

DECLARE @ReturnValue   int
SET @ReturnValue = 0

SELECT @NewAnnouncement = Announcement FROM Announcements

SET @CreateAnnouncement = 1

INSERT INTO Announcements (Announcement, UserName)
VALUES (@Announcement, @UserName)

谁能帮我解决这个问题?

4

1 回答 1

0

更换这部分

IF( @UserName.dbo.Announcements IS NULL ) -- not understandable what are you doing here

有了这个

IF( @UserName IS NULL ) 
于 2012-08-13T14:32:08.437 回答