Dynamically change a db in transact sql I am trying to run a script against a database that is dropped from a third party daily so the name of the database changes daily.  I can get the name of the new database using the sys.databases folder but I am trying to populate it into an SQL statement.  I am hoping to get this to run and move it into SSRS.  Thank you in advance.
You will want to use dynamic SQL to change the DB you are executing the query in:

DECLARE @dbname AS VARCHAR(100)
DECLARE @query AS VARCHAR(MAX)

SELECT @dbname = name
FROM sys.databases d
WHERE /*enter criteria here to get DB*/

SET @query = '
use ' + @dbname + '
/*enter your query here*/
'

PRINT @query
EXEC(@query)