sql server - Run long SQL script for each database -


i have long sql script i'd run each of databases on 1 server. what's best way that?

i found in research:

exec    sp_msforeachdb  " if      '?'     in ('lib1','lib2','lib3')     begin         use ?;         exec 'my_sp_long_sql_script' end " 

i tried needed me create sp in each library, kind of defeats purpose of loop. or how automate creating sp each library?

all want run long_sql_script each of databases.

use qualified name of stored procedure instead of relative name, retrieve whereever defined. how sql server works.


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -