I have a simple table type:CREATE TYPE [dbo].[int_list_tbltype] AS TABLE( [ID] INT NULL)GO
It's populated and goes into the stored procedure just fine.And the sql below works great.@ID INT,@UpdatedByID INT,@RoleIDList dbo.int_list_tbltype READONLYDELETE FROM UserRoles WHERE UserID = @IDINSERT INTO UserRoles (UserID, RoleID, UpdatedBy, UpdatedDate) SELECT @ID, ID, @UpdatedByID , GETDATE() FROM @RoleIDList
Even though roles my not be updated often, I still don't want to delete all roles for a user then add them again, taking or adding some, or even deleting all of them then adding them all again, even if there were no changes especially since this isn't all the sp does.Is there a way to compare what is in the role table vs. what is in the table param?Then insert and delete only if needed.Thank for any input.