I am trying to use the following stored procedure to obtain databases from a server. However, I just want the databases created from a month ago. What do I have to do to make this work?
Here is the code:
sp_msforeachdb 'IF ''?'' like ''z%''
BEGIN
print ''?''
END'
I just want the databases that begin with Z that were created during a certain month.
How about this instead.
select name
from sys.databases
where name like 'z%'
and create_date >= dateadd(mm,-1,getdate())