+ Reply to Thread
Results 1 to 6 of 6

batch file

  1. batch file

    hi,

    I have the following in a batch file, intended to run a sql file.. it opens
    up the SQL file, but does not actually execute it. Am I missing something?
    I have looked at and tried tons of example...


    C:\Program Files\Microsoft SQL Server\90\Tools\Binn\sqlcmd.exe -i
    c:\zigzag.sql -o c:\tiki.log


    pause


    Thanks in advance,
    geebee


  2. Re: batch file

    On Tue, 27 Jul 2010 11:38:21 -0700, geebee
    wrote:

    >I have the following in a batch file, intended to run a sql file.. it opens
    >up the SQL file, but does not actually execute it. Am I missing something?
    >I have looked at and tried tons of example...
    >
    >C:\Program Files\Microsoft SQL Server\90\Tools\Binn\sqlcmd.exe -i

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    I do not know if this is it, but this filename contains spaces.
    It should be quoted.

    >c:\zigzag.sql -o c:\tiki.log
    >
    >
    >pause


    Sincerely,

    Gene Wirchenko

  3. Re: batch file

    hi,

    there were no spaces originally. im just not sure what i could be doing
    wrong.

    thanks in advance,
    geebee


    "Gene Wirchenko" wrote:

    > On Tue, 27 Jul 2010 11:38:21 -0700, geebee
    > wrote:
    >
    > >I have the following in a batch file, intended to run a sql file.. it opens
    > >up the SQL file, but does not actually execute it. Am I missing something?
    > >I have looked at and tried tons of example...
    > >
    > >C:\Program Files\Microsoft SQL Server\90\Tools\Binn\sqlcmd.exe -i

    > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    > I do not know if this is it, but this filename contains spaces.
    > It should be quoted.
    >
    > >c:\zigzag.sql -o c:\tiki.log
    > >
    > >
    > >pause

    >
    > Sincerely,
    >
    > Gene Wirchenko
    > .
    >


  4. Re: batch file

    [reordered to chronological]

    On Wed, 28 Jul 2010 09:10:33 -0700, geebee
    wrote:

    >"Gene Wirchenko" wrote:
    >
    >> On Tue, 27 Jul 2010 11:38:21 -0700, geebee
    >> wrote:
    >>
    >> >I have the following in a batch file, intended to run a sql file.. it opens
    >> >up the SQL file, but does not actually execute it. Am I missing something?
    >> >I have looked at and tried tons of example...
    >> >
    >> >C:\Program Files\Microsoft SQL Server\90\Tools\Binn\sqlcmd.exe -i

    >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    >> I do not know if this is it, but this filename contains spaces.
    >> It should be quoted.
    >>
    >> >c:\zigzag.sql -o c:\tiki.log
    >> >
    >> >
    >> >pause


    >there were no spaces originally. im just not sure what i could be doing
    >wrong.


    Take a look at the caretted filename. I very much doubt that you
    have a directory name
    C:\ProgramFiles
    rather than
    C:\Program Files
    on your system.

    If there are any spaces in the path or the filename, quote the
    whole thing. Quoting will not hurt if there are no spaces.

    Sincerely,

    Gene Wirchenko

  5. Re: batch file

    Hi,
    I now have:
    "C:\Program Files\Microsoft SQL Server\90\Tools\Binn\sqlcmd.exe -i
    c:\zigzag.sql -o c:\tiki.log"

    pause

    It opens up the query, but does not execute it, and the batch window has all
    of the following in it:
    C:\>"C:\Program Files\Microsoft SQL Server\90\Tools\Binn\sqlcmd.exe -i
    ' "C:\Program Files\Microsoft SQL Server\90\Tools\Binn\sqlcmd.exe -i ' is
    not recognized as an internal or external command,
    operable program or batch file.

    c:\zigzag.sql -o c:\tiki.log"
    c:\>pause


    not sure what i need to change.


    thanks in advance,
    geebee

    "Gene Wirchenko" wrote:

    > [reordered to chronological]
    >
    > On Wed, 28 Jul 2010 09:10:33 -0700, geebee
    > wrote:
    >
    > >"Gene Wirchenko" wrote:
    > >
    > >> On Tue, 27 Jul 2010 11:38:21 -0700, geebee
    > >> wrote:
    > >>
    > >> >I have the following in a batch file, intended to run a sql file.. it opens
    > >> >up the SQL file, but does not actually execute it. Am I missing something?
    > >> >I have looked at and tried tons of example...
    > >> >
    > >> >C:\Program Files\Microsoft SQL Server\90\Tools\Binn\sqlcmd.exe -i
    > >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    > >> I do not know if this is it, but this filename contains spaces.
    > >> It should be quoted.
    > >>
    > >> >c:\zigzag.sql -o c:\tiki.log
    > >> >
    > >> >
    > >> >pause

    >
    > >there were no spaces originally. im just not sure what i could be doing
    > >wrong.

    >
    > Take a look at the caretted filename. I very much doubt that you
    > have a directory name
    > C:\ProgramFiles
    > rather than
    > C:\Program Files
    > on your system.
    >
    > If there are any spaces in the path or the filename, quote the
    > whole thing. Quoting will not hurt if there are no spaces.
    >
    > Sincerely,
    >
    > Gene Wirchenko
    > .
    >


  6. Re: batch file

    geebee (geraldjr30athotmaildotcom(noSPAMs)) writes:
    > I now have:
    > "C:\Program Files\Microsoft SQL Server\90\Tools\Binn\sqlcmd.exe -i
    > c:\zigzag.sql -o c:\tiki.log"


    That is not correct. You need the double quotes to specify the command,
    since there are spaces in the file path. The correct command should be:

    "C:\Program Files\Microsoft SQL Server\90\Tools\Binn\sqlcmd.exe" -i c:\zigzag.sql -o c:\tiki.log



    --
    Erland Sommarskog, SQL Server MVP, esquelatsommarskogdotse

    Links for SQL Server Books Online:
    SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
    SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
    SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx


+ Reply to Thread