Checking if a SQL Server login already exists

前端 未结 10 2111
盖世英雄少女心
盖世英雄少女心 2020-12-12 12:27

I need to check if a specific login already exists on the SQL Server, and if it doesn\'t, then I need to add it.

I have found the following code to actually add the

10条回答
  •  南笙
    南笙 (楼主)
    2020-12-12 12:36

    As a minor addition to this thread, in general you want to avoid using the views that begin with sys.sys* as Microsoft is only including them for backwards compatibility. For your code, you should probably use sys.server_principals. This is assuming you are using SQL 2005 or greater.

提交回复
热议问题