I am looking for the best way to check that a database login exists in SQL Server 2005. I am currently using
IF suser_sid('loginname') IS NOT NULL
but suser_sid() returns a value in some cases where a login does not exist.
In SQL 2000 we use
SELECT * FROM [Master].[dbo].[sysxlogins] WHERE [name] ='loginname'
but that table does not exist in SQL 2005.
There is a similar question about checking the existence of Users, which is helpful, but I am looking for the existence of Logins.
For sql2005…