Hello,
I'm trying to figure out how to do an inline variable substitution. I'm attempting to write a SP that cleans up temp tables users tend to leave behind for various reasons. To do this I create a cursor of all databases then I create another cursor with a dynamic drop table statement. In it I reference a declared varible @db_name.
Here is part of my sql
DECLARE tablenames CURSOR FOR
SELECT 'DROP TABLE ' + user_name(uid) + '.' + o.name
FROM @db_name..sysobjects o, master.dbo.spt_values v, master.dbo.spt_values x
WHERE o.name like 'temp%' ... and {add'l clauses}
its the @db_name.sysobjects that does not work. I need it to translate to {databasename}.sysobjects such as upg30.sysobjects. Any suggestions?
TIA,
-Isaac