Operand type clash: uniqueidentifier is incompatible with int

hughesdan picture hughesdan · Sep 12, 2011 · Viewed 126.2k times · Source

When I attempt to create the stored procedure below I get the following error:

Operand type clash: uniqueidentifier is incompatible with int

It's not clear to me what is causing this error. UserID is in fact an int in all of my tables. Can someone tell me what I've done wrong?

create procedure dbo.DeleteUser(@UserID int)
as

    delete from [aspnet_Membership] where UserId = @UserID
    delete from [Subscription] where UserID = @UserID
    delete from [Address] where UserID = @UserID
    delete from [User] where UserID = @UserID

go

Answer

Aaron Bertrand picture Aaron Bertrand · Sep 12, 2011

Sounds to me like at least one of those tables has defined UserID as a uniqueidentifier, not an int. Did you check the data in each table? What does SELECT TOP 1 UserID FROM each table yield? An int or a GUID?

EDIT

I think you have built a procedure based on all tables that contain a column named UserID. I think you should not have included the aspnet_Membership table in your script, since it's not really one of "your" tables.

If you meant to design your tables around the aspnet_Membership database, then why are the rest of the columns int when that table clearly uses a uniqueidentifier for the UserID column?