Drop SQL login even while logged in

前端 未结 6 1380
感动是毒
感动是毒 2021-02-05 01:25

When dropping a SQL Server 2008 login as part of integration test execution I sometimes get the following error:

System.Data.SqlClient.SqlException: Cou

6条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-05 01:36

    In SqlServer Studio on the Master DB.

    Use the command sp_who2 to list the opened sessions.

    In the list find the spid for your user - there may be more than one - e.g. 999

    Use kill and the spid to close all the sessions e.g.: kill 999

    Then DROP LOGIN [theuser]

提交回复
热议问题