Say I have 2 files:
do_me_first.sql
do_me_second.sql
And I issue:
> sqlcmd -S localhost -i do_me_first.sql
What syntax would put in do_me_first.sql so that it would execute
do_me_second.sql without any further sqlcmd invocations?
In Oracle with Sql*Plus, I would use an "at sign" like this in
do_me_first.sql :
@.do_me_second.sql
I'm still getting used to Microsoft documentation, and I cannot for
the life of me find a reference to such syntax.Hi,
You could try xp_cmdshell.
--
Thank you,
Daniel Jameson
SQL Server DBA
Children's Oncology Group
www.childrensoncologygroup.org
"cleveridea" <cleveridea.net@.gmail.com> wrote in message
news:1189639150.068229.71660@.r29g2000hsg.googlegroups.com...
> Say I have 2 files:
> do_me_first.sql
> do_me_second.sql
> And I issue:
>> sqlcmd -S localhost -i do_me_first.sql
> What syntax would put in do_me_first.sql so that it would execute
> do_me_second.sql without any further sqlcmd invocations?
> In Oracle with Sql*Plus, I would use an "at sign" like this in
> do_me_first.sql :
> @.do_me_second.sql
> I'm still getting used to Microsoft documentation, and I cannot for
> the life of me find a reference to such syntax.
>|||Hi,
You could also use a batch/command file to call sqlcmd twice. (If you're a
UNIX person, batch/command files are like shell scripts).
--
Thank you,
Daniel Jameson
SQL Server DBA
Children's Oncology Group
www.childrensoncologygroup.org
"cleveridea" <cleveridea.net@.gmail.com> wrote in message
news:1189639150.068229.71660@.r29g2000hsg.googlegroups.com...
> Say I have 2 files:
> do_me_first.sql
> do_me_second.sql
> And I issue:
>> sqlcmd -S localhost -i do_me_first.sql
> What syntax would put in do_me_first.sql so that it would execute
> do_me_second.sql without any further sqlcmd invocations?
> In Oracle with Sql*Plus, I would use an "at sign" like this in
> do_me_first.sql :
> @.do_me_second.sql
> I'm still getting used to Microsoft documentation, and I cannot for
> the life of me find a reference to such syntax.
>|||On Sep 12, 7:07 pm, "Daniel Jameson" <danja...@.newsgroup.nospam>
wrote:
> Hi,
> You could also use a batch/command file to call sqlcmd twice. (If you're a
> UNIX person, batch/command files are like shell scripts).
Thanks Daniel, I'm well aware of using multiple sqlcmd statements
wrapped in a batch file. However, I'm looking very specifically to
implement a simple approach where the person executing the deployment
script has an ultra-simple single invocation of a single sqlcmd
against a single infile sql script and I get the convenience and best
practice of dividing and conquering with my scripting files rather
than having one giant sql script file.|||> Say I have 2 files:
> do_me_first.sql
> do_me_second.sql
> And I issue:
>> sqlcmd -S localhost -i do_me_first.sql
> What syntax would put in do_me_first.sql so that it would execute
> do_me_second.sql without any further sqlcmd invocations?
Try:
:r do_me_first.sql
:r do_me_second.sql
You'll need to include a GO batch terminator after the :r file include if
you want to run the script immediately, unless the script is already
terminated with a GO. See the SQLCMD commands topic in the Books Online for
more information.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"cleveridea" <cleveridea.net@.gmail.com> wrote in message
news:1189639150.068229.71660@.r29g2000hsg.googlegroups.com...
> Say I have 2 files:
> do_me_first.sql
> do_me_second.sql
> And I issue:
>> sqlcmd -S localhost -i do_me_first.sql
> What syntax would put in do_me_first.sql so that it would execute
> do_me_second.sql without any further sqlcmd invocations?
> In Oracle with Sql*Plus, I would use an "at sign" like this in
> do_me_first.sql :
> @.do_me_second.sql
> I'm still getting used to Microsoft documentation, and I cannot for
> the life of me find a reference to such syntax.
>|||On Sep 12, 9:50 pm, "Dan Guzman" <guzma...@.nospam-
online.sbcglobal.net> wrote:
> > Say I have 2 files:
> > do_me_first.sql
> > do_me_second.sql
> > And I issue:
> >> sqlcmd -S localhost -i do_me_first.sql
> > What syntax would put in do_me_first.sql so that it would execute
> > do_me_second.sql without any further sqlcmd invocations?
> Try:
> :r do_me_first.sql
> :r do_me_second.sql
> You'll need to include a GO batch terminator after the :r file include if
> you want to run the script immediately, unless the script is already
> terminated with a GO. See the SQLCMD commands topic in the Books Online for
> more information.
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "cleveridea" <cleveridea...@.gmail.com> wrote in message
> news:1189639150.068229.71660@.r29g2000hsg.googlegroups.com...
> > Say I have 2 files:
> > do_me_first.sql
> > do_me_second.sql
> > And I issue:
> >> sqlcmd -S localhost -i do_me_first.sql
> > What syntax would put in do_me_first.sql so that it would execute
> > do_me_second.sql without any further sqlcmd invocations?
> > In Oracle with Sql*Plus, I would use an "at sign" like this in
> > do_me_first.sql :
> > @.do_me_second.sql
> > I'm still getting used to Microsoft documentation, and I cannot for
> > the life of me find a reference to such syntax.
This is PERFECT. Thank you so much. After 10 years with Oracle and 5
each with MySQL and PostgreSQL it is remarkable how feeble I feel
doing the simplest thing with scripting particulars of SQL Server.
I've got the Books Online link in my favorites for future problems.