Created
November 27, 2017 04:48
-
-
Save smarenich/47582240a6fd6ed7fee47777d4dd6457 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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