标签:distrib where strong cer algorithm its failed ble dea
--drop table #UserDB
--drop table #DB_Role
Create table #DB_Role
(
DBName varchar(100) null,
UserName varchar(100),
RoleName Varchar(1000),
LoginName Varchar(100),
DefDBName varchar(100),
DefSchemaName varchar(100),
UserID varchar(100),
SID varchar(1000))
Create table #UserDB
(name varchar(1000));
insert into #UserDB
select name from sys.databases where name not in
(N‘master‘, N‘model‘, N‘msdb‘, N‘tempdb‘, N‘distribution‘, N‘DWDiagnostics‘, N‘DWConfiguration‘, N‘DWQueue‘, N‘resource‘,N‘ReportServer‘,N‘ReportServerTempDB‘)
Declare @UserDB nvarchar(1000);
Declare DBrole_cursor cursor
for
select * from #UserDB;
open DBrole_cursor;
fetch next from DBrole_cursor into @UserDB;
while @@FETCH_STATUS=0
begin
Declare @DBrole_SQL varchar(1000)
set @DBrole_SQL=
‘use ‘+QUOTENAME(@UserDB,‘[]‘)+‘;
insert into #DB_Role
(
UserName,
RoleName,
LoginName,
DefDBName,
DefSchemaName,
UserID,
SID) exec sp_helpuser;
update #DB_Role set DBName=‘+‘‘‘‘+@UserDB+‘‘‘‘+‘ where DBName is null
‘
print (@DBrole_SQL)
exec (@DBrole_SQL)
fetch next from DBrole_cursor into @UserDB;
end
close DBrole_cursor;
deallocate DBrole_cursor;
select * from #DB_Role
批量对数据库进行TDE加密:
Use [ITSP_Audit]
--drop table #Failed_List
--drop table #Column
Declare @Columns varchar(100)
create table #Failed_List
(Server_Name varchar(100),
Failed_Item Varchar(100)
)
Declare ColumnName cursor for
select name from sys.columns where OBJECT_ID=object_id(‘AuditItem‘)
open ColumnName;
Fetch next from ColumnName into @Columns;
while @@FETCH_STATUS=0
Begin
create table #Column
(Column_name varchar(100))
insert into #Column select @Columns
Declare @SQL varchar(1000)
set @SQL=‘Insert into #Failed_List
select a.ServerName, b.Column_name from AuditItem a
,#Column b
where ‘+@Columns+‘ like ‘+‘‘‘%Miss%‘‘‘
Print (@SQL)
Exec (@SQL)
drop table #Column
fetch next from ColumnName into @Columns;
end
close ColumnName
deallocate ColumnName
select * from #Failed_List order by Server_Name,Failed_Item
select * from [dbo].[AuditItem]
标签:distrib where strong cer algorithm its failed ble dea
原文地址:https://www.cnblogs.com/LC0507/p/11177595.html