Skip to content

Instantly share code, notes, and snippets.

@smarenich
Created November 27, 2017 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smarenich/47582240a6fd6ed7fee47777d4dd6457 to your computer and use it in GitHub Desktop.
Save smarenich/47582240a6fd6ed7fee47777d4dd6457 to your computer and use it in GitHub Desktop.
if exists(select * from sys.triggers where parent_id = object_id('Users') and name = 'SuncUserPassword')
Drop trigger dbo.SuncUserPassword
GO
Create trigger dbo.SuncUserPassword on dbo.Users for Update as
Begin
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
End
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment