Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
if exists(select * from sys.triggers where parent_id = object_id('Users') and name = 'SuncUserPassword')
Drop trigger dbo.SuncUserPassword
Create trigger dbo.SuncUserPassword on dbo.Users for Update as
declare @companyID int
select @companyID = CompanyID from inserted
Update u Set Password = i.Password from [dbo].[Users] u
inner join inserted i on u.CompanyID <> @companyID and u.Username = i.Username
Where u.CompanyID > 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment