Test for database users before creating them
For example, add an "IF" as below:
IF NOT EXISTS (SELECT * FROM sys.database_principals where name = 'xxx\yyyyyy')
CREATE USER [xxx\yyyyyy] FOR LOGIN [xxx\yyyyyy]
GO
7
votes
David Rogers
shared this idea
-
Viv Johnston commented
Just started using Flyway to deploy DB changes and the baseline script always needs updating, open have multiple users we need to update.
-
Chris Stevens commented
This would be nice and here are my comments in detail.
https://forum.red-gate.com/discussion/82164/create-user-should-have-if-not-exists#latest