SQL Server - Check if login exists (SQL Server 2000)

Compatible from SQL Server 2000

Verify if required login exists in SQL Server 2000 instance and affect workflow. This is simple query to system view sys.syslogins. Checking for existence of principal with given name. So this is useful in workflows where you need to create or drop logins from your program.

INFO: SQL Server 2000 system table sys.syslogins is included as a view for backward compatibility. Use the current SQL Server system views instead. To find the equivalent system view or views, see Mapping System Tables to System Views (Transact-SQL). This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.

IF EXISTS (SELECT * FROM master.sys.syslogins WHERE NAME = 'login name') 
	-- do your magic here
	-- do another magic here

Related posts

Leave a Reply

Your email address will not be published. Required fields are marked *