Blog Pages

Exclude records from a select according to a comma separate list is a string

declare @pDBNameExcludeList varchar(max) = 'master,model,msdb'

select *
from sys.databases d
where upper(','+replace(replace(coalesce(@pDBNameExcludeList,'[]'),'[',''),']','')+',') 
not like upper('%'+name+'%')

No comments:

Post a Comment