T-SQL sp_msforeachdb problem I am trying to compare the database name using the ? operator in the sp_msforeachdb function.  Here is a snippet:

EXEC master..sp_msforeachdb '

USE [?];
IF NOT EXISTS (
    SELECT db_name(database_id) as [database] 
    FROM sys.dm_database_encryption_keys 
    WHERE [Database] = ''?'')
BEGIN
...
'


Basically, I want to be able to find the databases that do not have an encryption key and begin/end a transaction ELSE begin/end a different transaction.
? stands for the datbase name and sys.dm_database_encryption_keys holds database_id.

exec master..sp_msforeachdb
'
IF NOT EXISTS 
(
    SELECT  null
    FROM    [?].sys.dm_database_encryption_keys 
    WHERE   database_id = db_id(''?'')
)
BEGIN
    print ''?''
END
'