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
Best Solution
Sounds to me like at least one of those tables has defined
UserID
as auniqueidentifier
, not anint
. Did you check the data in each table? What doesSELECT TOP 1 UserID FROM
each table yield? Anint
or aGUID
?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 columnsint
when that table clearly uses auniqueidentifier
for theUserID
column?