USE [EnVisage]
GO

/****** Object:  StoredProcedure [dbo].[sp_DeleteUser]    Script Date: 6/16/2015 8:53:49 PM ******/
if exists (select 1 from sys.procedures where name like 'sp_DeleteUser')
BEGIN
	DROP PROCEDURE [dbo].[sp_DeleteUser]
END
GO

/****** Object:  StoredProcedure [dbo].[sp_DeleteUser]    Script Date: 6/16/2015 8:53:49 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[sp_DeleteUser] (@Id uniqueidentifier) AS
	BEGIN
	
		BEGIN TRANSACTION

		delete from User2Team where UserId = @Id
		delete from User2View where UserId = @Id
		delete from UserPreferences where UserId = @Id
		delete from AspNetUserClaims where [User_Id] = @Id
		delete from AspNetUserLogins where [UserId] = @Id
		delete from AspNetUserRoles where [UserId] = @Id
		delete from AspNetUsers where id = @Id

		COMMIT TRANSACTION 

 	END

GO


