I'm creating a few migration scripts to generate a sql server database from scratch.
In my '0005-create_login.up.sql' script I have something like:
CREATE LOGIN [mylogin] WITH PASSWORD=N'xxx=',
GO
And in my '0005-create_login.down.sql'
DROP LOGIN [appws]
GO
Now I'd like to drop the login only if it is not being used in another database. I had a look at sp_helplogins code with:
sp_helptext 'sp_helplogins'
but it's really complex. I wonder if there's and easier way to get a login with the databases it is being used.