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 -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -