Link to home
Create AccountLog in
Avatar of John Miller
John Miller

asked on

SQL SERVER - Store Procedure

I have a SP in which i need to add one condition to check multiple databases by using sys.dm_database_encryption_keys table.

when encryption_state is 2 and percentage_completed is 0 in the results it should print the query i will provide.
Avatar of Nitin Sontakke
Nitin Sontakke
Flag of India image

So? Where are you stuck?

Have you tried something?
Avatar of John Miller
John Miller

ASKER

I tried this

DECLARE @Test varchar(10)
SELECT @Test = Database_ID from
                             sys.dm_database_encryption_keys  
WHERE Encryption_state = 2 and complete_percentage = 0
If (@test not NULL)
Begin
PRINT("ALTER DB NAme")

If i have multiple DB's which meets the about. It should PRINT multiple ALTER statements with DB Names.
ASKER CERTIFIED SOLUTION
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
John, a feedback will be appreciated.
Recommendation to close this question by accepting the above comments as solutions.