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

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -