當用戶更新他的個人資料圖片時,我想將其插入到表中並更新另一個表中的兩列。它工作正常,只是一個入口和停止更新第二個表..不知道什麼是我創建了一個小提琴錯誤在單個存儲過程中插入和更新不起作用
ALTER PROCEDURE [dbo].[UploadProfilePic]
(@UserName Nvarchar(50),
@ImageName Nvarchar(max),
@OrgImageName Nvarchar(max),
@CommentImage Nvarchar(max))
AS
BEGIN
IF NOT EXISTS (SELECT Username FROM ProfilePic WHERE UserName = @UserName)
Begin
insert into ProfilePic ([UserName], [ImageName], [OrgImageName], [IsActive], [CommentImage])
values(@UserName, @ImageName, @OrgImageName, 'Y', @CommentImage)
Update UserProfile
set ProfileImg = @ImageName,
PostImage = @CommentImage
where UserName = @UserName
END
ELSE
BEGIN
UPDATE ProfilePic
SET IsActive = 'N'
WHERE UserName = @UserName
INSERT INTO ProfilePic ([UserName], [ImageName], [OrgImageName], [IsActive],[CommentImage])
VALUES(@UserName, @ImageName, @OrgImageName, 'Y', @CommentImage)
END
END
接着說:SQL-server'標籤和'爲nvarchar(最大)'數據類型 – 2014-08-31 11:33:26