Hi guys I have written this stored procedure but there is an error in it that says
Cannot call methods on nvarchar
T-SQL code:
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)
Can anyone help me fix this problem please?
Replace this part
IF( @UserName.dbo.Announcements IS NULL ) -- not understandable what are you doing here
with this
IF( @UserName IS NULL )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.