Information générale
Forum:
Microsoft SQL Server
Michael,
Thanks for your suggestion.
I actually tried something like this on my first go around. But again, I could not figure out the syntax. That is I have var called @dbname, and I tried things like USE @dbname or setting another var with something like SELECT @cmd = "use " + @dbname then EXEC (@cmd) but either I got an error because of invalid syntax or sql server never actually changed dabatases.
I'm now thinking of putting a SP in each database then having a SP in master create a cursor of all databases and then doing something like
exec ('dbname.mysp') in a loop.
I'll keep playing with it.
Regards,
-Isaac
>TSQL does not allow you to parameterize the FROM clause of a query. What about making your cleanup routine a stored procedure. Prefix the name with sp_ and save it into the master database. Have another routine create a cursor of all the user databases and use dynamic sql to issue a USE command and execute your cleanup routine.
>
>-Mike
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement