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++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -