我收到错误“无法调用nvarchar上的方法”为什么?

时间:2012-08-13 14:22:21

标签: asp.net sql vb.net stored-procedures

大家好我已经编写了这个存储过程,但是它中有一个错误

  

无法在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)

有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

替换此部分

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

用这个

IF( @UserName IS NULL )