sp.crypmaster(cursor) automation update

 USE [DellPII]

GO


/****** Object:  StoredProcedure [dbo].[Sp_CryptMaster]    Script Date: 3/29/2022 10:40:15 AM ******/

SET ANSI_NULLS ON

GO


SET QUOTED_IDENTIFIER ON

GO




CREATE PROCEDURE [dbo].[Sp_CryptMaster]    

        

AS     

  

-----Declare the variables for holding data.   

SET NOCOUNT ON    


DECLARE @DBName NVARCHAR(MAX)  

DECLARE @TableName NVARCHAR(MAX)  

DECLARE @FieldName NVARCHAR(MAX)  

DECLARE @SecureID INT  

DECLARE @ClientParentID INT  

DECLARE @PriColumnName NVARCHAR(MAX)  

DECLARE @isactive INT 



--Declare Cursor    

DECLARE PIIDBConfig_CURSOR CURSOR   FOR

SELECT  DBName,TableName,FieldName,SecureID,ClientParentID,PriColumnName,ISactive

FROM  Dellpii.dbo.PIIDBConfigtest    

where ISActive=1

----Open Cursor  

OPEN PIIDBConfig_CURSOR    

----Fetch the record into the variables.   

FETCH NEXT FROM PIIDBConfig_CURSOR INTO  @DBName,@TableName,@FieldName, @SecureID,@ClientParentID,@PriColumnName,@isactive

----LOOP UNTIL RECORDS ARE AVAILABLE.    

WHILE @@FETCH_STATUS = 0    

BEGIN    


Declare @msg  nvarchar(500)

Declare @cnt int

EXECUTE  sp_dynamicupdate1 @TableName,@FieldName,@ClientParentID,@SecureID,@PriColumnName,@isactive,@message=@msg output,@count=@cnt output


execute sp_logging @cnt,@TableName,@FieldName,@secureid,@msg


FETCH NEXT FROM PIIDBConfig_CURSOR INTO   @DBName,@TableName,@FieldName, @SecureID,@ClientParentID,@PriColumnName,@isactive

END  

---Close Cursor--Deallocate Cursor  

CLOSE PIIDBConfig_CURSOR    

DEALLOCATE PIIDBConfig_CURSOR  



DECLARE @DBName2 NVARCHAR(MAX)  

DECLARE @TableName2 NVARCHAR(MAX)  

DECLARE @FieldName2 NVARCHAR(MAX)  

DECLARE @SecureID2 INT  

DECLARE @ClientParentID2 INT  

DECLARE @PriColumnName2 NVARCHAR(MAX)  

DECLARE @isactive2 INT 


 

 --Declare Cursor    

DECLARE PIIDBConfig_CURSOR2 CURSOR   FOR

SELECT  DBName,TableName,ClientParentID,PriColumnName

FROM  Dellpii.dbo.PIIDBConfigtest    

where ISActive=1

group by  DBName,TableName,PriColumnName,ClientParentID

ORDER BY TableName

----Open Cursor  

OPEN PIIDBConfig_CURSOR2    

----Fetch the record into the variables.   

FETCH NEXT FROM PIIDBConfig_CURSOR2 INTO @DBName2,@TableName2,@ClientParentID2,@PriColumnName2

----LOOP UNTIL RECORDS ARE AVAILABLE.    

WHILE @@FETCH_STATUS = 0    

BEGIN    


Declare @msg2  nvarchar(500)

Declare @cnt2 int


EXECUTE  sp_isencryptupdate @TableName2,@ClientParentID2,@PriColumnName2,@message=@msg2 output

execute sp_logging @cnt2,@TableName,@FieldName2,@secureid2,@msg2


FETCH NEXT FROM PIIDBConfig_CURSOR2 INTO   @DBName2,@TableName2,@PriColumnName2,@ClientParentID2

END  

---Close Cursor--Deallocate Cursor  

CLOSE PIIDBConfig_CURSOR2   

DEALLOCATE PIIDBConfig_CURSOR2  

 



GO



Comments

Popular posts from this blog

java chapter11 practice question on abstruct class and interfaces

DAY 12 -AZURE DP900(Microsoft Azure Data Fundamentals: Explore non-relational data in Azure)

java exercise4