Professional Web Applications Themes

Is it possible to run a SQL script from a batch file ? - Microsoft SQL / MS SQL Server

use osql inside the batch file , input the filename with -i parameter. -- -Vishal "ugotthe8" <com> wrote in message news:phx.gbl... ...

  1. #1

    Default Re: Is it possible to run a SQL script from a batch file ?

    use osql inside the batch file , input the filename with -i parameter.

    --
    -Vishal
    "ugotthe8" <com> wrote in message
    news:phx.gbl... 


    Vishal Guest

  2. #2

    Default Re: Is it possible to run a SQL script from a batch file ?

    DISCLAIMER: I have little SQL Server knowledge and there's a 50% chance I
    will post bad advice.

    You can execute osql in a batch.

    osql -S SERVERNAME -U SQLLogon -P ThePassword -i PathToFileWithSQLQuery

    You can build your SQL in the batch if you like by doing something like:

    ECHO SELECT [Something] FROM [Somewhere] WHERE
    [Something]='Something'>sql.txt

    You can pipe your query to a file by doing something like:

    osql -S SERVERNAME -U SQLLogon -P ThePassword -i
    PathToFileWithSQLQuery>results.txt

    Use >> if you'd like to append to a file instead of overwriting if you
    output to a file.

    Ray at work



    "ugotthe8" <com> wrote in message
    news:phx.gbl... 


    Ray Guest

  3. #3

    Default Re: Is it possible to run a SQL script from a batch file ?

    You can run SQL scripts files via the command line utility osql.

    For example:
    osql -E -i mybatch.sql

    You can find the complete syntax in Books Online or with osql /?

    --
    Jacco Schalkwijk MCDBA, MCSD, MCSE
    Database Administrator
    Eurostop Ltd.


    "ugotthe8" <com> wrote in message
    news:phx.gbl... 


    Jacco Guest

  4. #4

    Default Is it possible to run a SQL script from a batch file ?

    Yes.

    From Books OnLine (index osql Utility):

    Using osql Interactively
    To use osql interactively, type the osql command (and any
    of the options) at a command prompt.

    You can read in a file containing a query (such as
    Stores.qry) for execution by osql by typing a command
    similar to this:

    osql /U alma /P /i stores.qry


    Edgardo Valdez
    MCSD, MCDBA, MCSE, MCP+I
    Database Administrator
    http://www.edgardovaldez.us/

     
    Edgardo Guest

  5. #5

    Default Re: Is it possible to run a SQL script from a batch file ?

    Thanks all!

    "ugotthe8" <com> wrote in message
    news:phx.gbl... 


    ugotthe8 Guest

Similar Threads

  1. Batch Delete Script? maybe javascript?
    By Matthew_Brady@adobeforums.com in forum Adobe Acrobat Windows
    Replies: 0
    Last Post: April 5th, 02:36 PM
  2. How to develop an extension or batch processing script?
    By tirizar webforumsuser@macromedia.com in forum Macromedia Fireworks
    Replies: 1
    Last Post: August 18th, 10:44 PM
  3. Batch Script for generating 216 color images.
    By Peter Landis in forum Macromedia Fireworks
    Replies: 0
    Last Post: August 11th, 04:57 AM
  4. Batch Script returns "Could Not Run script - File was not found"
    By Al Tenuta in forum Macromedia Fireworks
    Replies: 3
    Last Post: August 8th, 11:34 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139