??????????SQL Server ?????Windows ????????
????SQL Server ???????????????????????
????1 select * from sys.sql_logins
??????????????????????????????????????????SQL Server??????????????????????Windows ????????
????Windows?????
????????????????????????
????SQL Server ??????????????????????????????SQL Server ??“??????”??Login???????????????SQL Server ??SQL????Windows ?????????SQL Server???ж???????????????????
???????????????е?“???”??User???????????????????ж?????????????????????????????SID????????????????SQL Server ?????????????????????????????
??????????????????????????
????1.????????y????????????????msdb????????????????????????????????????????????????????????????????????????????????????????????????????????μ?????????е???????????????????????????????????????????????????????????SID??????????????????????????????????????????ν??????????
????2.?????????????????????????????????????????????????????????????????????????????????????????????а??????????????????????????????豻??????????????????????????????μ???????
????????????????????110???????2012????????????????????
????1 EXEC sys.sp_configure N'contained database authentication'?? N'1'
????2 GO
????3 RECONFIGURE WITH OVERRIDE
????4 GO
???????[AdventureWorks2012]??????????
????1 USE [master]
????2 GO
????3 ALTER DATABASE [AdventureWorks2012] SET CONTAINMENT = PARTIAL WITH NO_WAIT
????4 GO
???????????????е?????????
????1 use master
????2 select * from sys.databases
????3 where containment >0
?????????е????????????????????????
1 USE [AdventureWorks2012]
2 GO
3 DECLARE @username SYSNAME;
4 DECLARE user_cursor CURSOR
5 FOR
6     SELECT  dp.name
7     FROM    sys.database_principals AS dp
8             JOIN sys.server_principals AS sp ON dp.sid = sp.sid
9     WHERE   dp.authentication_type = 1
10             AND sp.is_disabled = 0;
11 OPEN user_cursor
12 FETCH NEXT FROM user_cursor INTO @username
13 WHILE @@FETCH_STATUS = 0
14     BEGIN
15         EXECUTE sp_migrate_user_to_contained @username = @username??
16             @rename = N'keep_name'?? @disablelogin = N'disable_login';
17         FETCH NEXT FROM user_cursor INTO @username
18     END
19 CLOSE user_cursor;
20 DEALLOCATE user_cursor;