| Author |
Topic |
|
dwfresh
Starting Member
4 Posts |
Posted - 2008-08-05 : 16:58:04
|
| Hi guysI am getting this pesky error and I don't know why.Can someone tell me why I'm stuck. Im a newbie so please bear with me :)Msg 206, Level 16, State 2, Procedure sp_User_Create, Line 21Operand type clash: uniqueidentifier is incompatible with intHere is the stored procedure I am trying to create.I have a Users table. The 'UserId' column is the primary key (int), but I also have a 'Guid' column which is a uniqueidentifier.set ANSI_NULLS ONset QUOTED_IDENTIFIER ONgoCREATE PROCEDURE [dbo].[sp_User_Create] (@FirstName nvarchar(50), @LastName nvarchar(50), @LoginName nvarchar(50), @EgovUserProfileID int, @EgovUserToken nvarchar(256), @SecretQuestionId int, @SecretAnswer nvarchar(256), @MothersMaidenName nvarchar(50), @Ssn nvarchar(9), @UserId int OUTPUT, @Guid uniqueidentifier OUTPUT)ASBEGIN IF( @UserId IS NULL ) SELECT @UserId = NEWID() ELSE BEGIN IF( EXISTS( SELECT UserId FROM dbo.Users WHERE @UserId = UserId ) ) RETURN -1 END INSERT into dbo.Users (FirstName, LastName, LoginName, Ssn, EgovUserProfileID, EgovUserToken, SecretQuestionId, SecretAnswer, MothersMaidenName, CreateDate, LastLoginDate, Guid) VALUES (@FirstName, @LastName, LOWER(@LoginName), @Ssn, @EgovUserProfileID, @EgovUserToken, @SecretQuestionId, @SecretAnswer, @MothersMaidenName, GetDate(), Getdate(), newId()) RETURN 0END |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2008-08-05 : 17:13:52
|
quote: Originally posted by dwfresh Hi guysI am getting this pesky error and I don't know why.Can someone tell me why I'm stuck. Im a newbie so please bear with me :)Msg 206, Level 16, State 2, Procedure sp_User_Create, Line 21Operand type clash: uniqueidentifier is incompatible with intHere is the stored procedure I am trying to create.I have a Users table. The 'UserId' column is the primary key (int), but I also have a 'Guid' column which is a uniqueidentifier.set ANSI_NULLS ONset QUOTED_IDENTIFIER ONgoCREATE PROCEDURE [dbo].[sp_User_Create] (@FirstName nvarchar(50), @LastName nvarchar(50), @LoginName nvarchar(50), @EgovUserProfileID int, @EgovUserToken nvarchar(256), @SecretQuestionId int, @SecretAnswer nvarchar(256), @MothersMaidenName nvarchar(50), @Ssn nvarchar(9), @UserId int OUTPUT, @Guid uniqueidentifier OUTPUT)ASBEGIN IF( @UserId IS NULL ) SELECT @UserId = NEWID() ELSE BEGIN IF( EXISTS( SELECT UserId FROM dbo.Users WHERE @UserId = UserId ) ) RETURN -1 END INSERT into dbo.Users (FirstName, LastName, LoginName, Ssn, EgovUserProfileID, EgovUserToken, SecretQuestionId, SecretAnswer, MothersMaidenName, CreateDate, LastLoginDate, Guid) VALUES (@FirstName, @LastName, LOWER(@LoginName), @Ssn, @EgovUserProfileID, @EgovUserToken, @SecretQuestionId, @SecretAnswer, @MothersMaidenName, GetDate(), Getdate(), newId()) RETURN 0END
>>SELECT @UserId = NEWID()You have declared @userid as an INT. Did you mean "select @guid = newid()" ?EDITI:How are new UserIDs created? I guess that is what you are trying to do. Perhaps UserID should be an identity column. And what purpose is the GUID column going to serve?Be One with the OptimizerTG |
 |
|
|
dwfresh
Starting Member
4 Posts |
Posted - 2008-08-05 : 17:26:05
|
| ahh yes, thank you.I use GUIDs for added security and as a truly unique identifier for a user, for cookies, etc. |
 |
|
|
|
|
|