当我试图执行这个存储过程时,我面临一个错误 int is int is incompatable with uniqueidentifier.my userid coloumn is bigint
使用 [iFlipOut_Dev] 去 / *对象:StoredProcedure [dbo].[SaveRegistration] 脚本日期:2013 年 4 月 14 日下午 3:29:40* / SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON GO
ALTER PROCEDURE [dbo].[SaveRegistration]
(
@p_UserId int,
@p_FirstName nvarchar(150),
@p_LastName nvarchar(50),
@p_Gender nvarchar(10),
@p_Email nvarchar(150),
@p_Mobile nvarchar(12),
@p_Phone nvarchar(12),
@p_DateOfBirth nvarchar(50),
@p_Address nvarchar(250),
@p_ZipCode nvarchar(10),
@p_City nvarchar(100),
@p_StateId smallint,
@p_LoginId int,
@p_UserStatusId smallint,
@p_LanguageId smallint,
@p_ModifiedBy bigint,
@p_CountryId smallint,
@p_UserImage nvarchar(20),
@p_publicRegistrationId nvarchar(50),
@p_TimeZone_Id smallint
)
AS
BEGIN
SET NOCOUNT ON
IF
CASE
WHEN EXISTS
(
SELECT
UD.UserId,
UD.FirstName,
UD.LastName,
UD.Gender,
UD.email,
UD.Mobile,
UD.phone,
UD.DateOfBirth,
UD.Address,
UD.ZipCode,
UD.City,
UD.StateId,
UD.LoginId,
UD.UserStatusId,
UD.LanguageId,
UD.ModifiedBy,
UD.ModifiedDate,
UD.CountryId,
UD.UserImage,
UD.PublicRegistrationId,
UD.TimeZone_Id,
UD.IsActivated
FROM dbo.UserDetails as UD
WHERE UD.UserId = @p_UserId
) THEN 1
ELSE 0
END <> 0
/*
* Added UserId Coloumn to be inserted in the table
*/
UPDATE dbo.UserDetails
SET
FirstName = @p_FirstName,
LastName = @p_LastName,
Gender = @p_Gender,
Email = @p_Email,
Mobile = @p_Mobile,
Phone = @p_Phone,
DateOfBirth = @p_DateOfBirth,
Address = @p_Address,
ZipCode = @p_ZipCode,
City = @p_City,
StateId = @p_StateId,
LoginId = @p_LoginId,
UserStatusId = @p_UserStatusId,
LanguageId = @p_LanguageId,
ModifiedBy = @p_ModifiedBy,
ModifiedDate = isnull(getdate(), getdate()),
CountryId = @p_CountryId,
UserImage = @p_UserImage,
PublicRegistrationId=@p_publicregistrationId,
TimeZone_Id = @p_TimeZone_Id
WHERE UserDetails.UserId = @p_UserId
ELSE
BEGIN
/*
* added userid coloumn in the insert statement
*/
INSERT dbo.UserDetails(
dbo.UserDetails.FirstName,
dbo.UserDetails.LastName,
dbo.UserDetails.Gender,
dbo.UserDetails.email,
dbo.UserDetails.Mobile,
dbo.UserDetails.Phone,
dbo.UserDetails.DateOfBirth,
dbo.UserDetails.Address,
dbo.UserDetails.ZipCode,
dbo.UserDetails.City,
dbo.UserDetails.StateId,
dbo.UserDetails.LoginId,
dbo.UserDetails.UserStatusId,
dbo.UserDetails.LanguageId,
dbo.UserDetails.ModifiedBy,
dbo.UserDetails.ModifiedDate,
dbo.UserDetails.CountryId,
dbo.UserDetails.UserImage,
dbo.UserDetails.PublicRegistrationId,
dbo.UserDetails.TimeZone_Id)
VALUES (
@p_FirstName,
@p_LastName,
@p_Gender,
@p_Email,
@p_Mobile,
@p_Phone,
@p_DateOfBirth,
@p_Address,
@p_ZipCode,
@p_City,
@p_StateId,
@p_LoginId,
@p_UserStatusId,
@p_LanguageId,
@p_ModifiedBy,
isnull(getdate(), getdate()),
@p_CountryId,
@p_UserImage,
newid(),
@p_TimeZone_Id)
SET @p_UserId = scope_identity()
END
SELECT @p_UserId AS UserId
END