sql server: how to execute a .sql from another query? -


i have .sql script lot of action queries work on staging tables. script needs run twice other commands in-between i.e.:

  1. load staging table source a
  2. use do_stuff.sql process it
  3. move results somewhere.
  4. repeat steps 1-3 source b.

the brute force approach copy & paste dostuff.sql needed. while technically work, there better way?

i'm hoping there's command runthissql 'c:\do_stuff.sql' haven't discovered yet.

if use visual studio can create "sql server database" project. withing project can create script let execute *.sql files in manner

 /* post-deployment script template                          --------------------------------------------------------------------------------------  file contains sql statements appended build script.         use sqlcmd syntax include file in post-deployment script.           example:      :r .\myfile.sql                                use sqlcmd syntax reference variable in post-deployment script.         example:      :setvar tablename mytable                                            select * [$(tablename)]                  -------------------------------------------------------------------------------------- */ 

see also. http://candordeveloper.com/2013/01/08/creating-a-sql-server-database-project-in-visual-studio-2012/


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -