Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL Server Command Line Compile

SQL Server Command Line Compile

Scheduled Pinned Locked Moved Database
databasesql-serversysadmintoolsquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kevin Marois
    wrote on last edited by
    #1

    It is possible to compile a SQL script via a command line?

    Everything makes sense in someone's mind

    P B 2 Replies Last reply
    0
    • K Kevin Marois

      It is possible to compile a SQL script via a command line?

      Everything makes sense in someone's mind

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      You don't compile SQL. You can execute SQL statements or a file of statements depending on the database system. For SQL Server, see sqlcmd

      C:>sqlcmd /?
      Microsoft (R) SQL Server Command Line Tool
      Version 10.50.2500.0 NT x64
      Copyright (c) Microsoft Corporation. All rights reserved.

      usage: Sqlcmd [-U login id] [-P password]
      [-S server] [-H hostname] [-E trusted connection]
      [-N Encrypt Connection][-C Trust Server Certificate]
      [-d use database name] [-l login timeout] [-t query timeout]
      [-h headers] [-s colseparator] [-w screen width]
      [-a packetsize] [-e echo input] [-I Enable Quoted Identifiers]
      [-c cmdend] [-L[c] list servers[clean output]]
      [-q "cmdline query"] [-Q "cmdline query" and exit]
      [-m errorlevel] [-V severitylevel] [-W remove trailing spaces]
      [-u unicode output] [-r[0|1] msgs to stderr]
      [-i inputfile] [-o outputfile] [-z new password]
      [-f | i:[,o:]] [-Z new password and exit]
      [-k[1|2] remove[replace] control characters]
      [-y variable length type display width]
      [-Y fixed length type display width]
      [-p[1] print statistics[colon format]]
      [-R use client regional setting]
      [-b On error batch abort]
      [-v var = "value"...] [-A dedicated admin connection]
      [-X[1] disable commands, startup script, enviroment variables [and exit]]
      [-x disable variable substitution]
      [-? show syntax summary]

      K 1 Reply Last reply
      0
      • P PIEBALDconsult

        You don't compile SQL. You can execute SQL statements or a file of statements depending on the database system. For SQL Server, see sqlcmd

        C:>sqlcmd /?
        Microsoft (R) SQL Server Command Line Tool
        Version 10.50.2500.0 NT x64
        Copyright (c) Microsoft Corporation. All rights reserved.

        usage: Sqlcmd [-U login id] [-P password]
        [-S server] [-H hostname] [-E trusted connection]
        [-N Encrypt Connection][-C Trust Server Certificate]
        [-d use database name] [-l login timeout] [-t query timeout]
        [-h headers] [-s colseparator] [-w screen width]
        [-a packetsize] [-e echo input] [-I Enable Quoted Identifiers]
        [-c cmdend] [-L[c] list servers[clean output]]
        [-q "cmdline query"] [-Q "cmdline query" and exit]
        [-m errorlevel] [-V severitylevel] [-W remove trailing spaces]
        [-u unicode output] [-r[0|1] msgs to stderr]
        [-i inputfile] [-o outputfile] [-z new password]
        [-f | i:[,o:]] [-Z new password and exit]
        [-k[1|2] remove[replace] control characters]
        [-y variable length type display width]
        [-Y fixed length type display width]
        [-p[1] print statistics[colon format]]
        [-R use client regional setting]
        [-b On error batch abort]
        [-v var = "value"...] [-A dedicated admin connection]
        [-X[1] disable commands, startup script, enviroment variables [and exit]]
        [-x disable variable substitution]
        [-? show syntax summary]

        K Offline
        K Offline
        Kevin Marois
        wrote on last edited by
        #3

        I guess I meant Parse. In SSMS there's a parse option. Can this be done on a command line?

        Everything makes sense in someone's mind

        P 1 Reply Last reply
        0
        • K Kevin Marois

          I guess I meant Parse. In SSMS there's a parse option. Can this be done on a command line?

          Everything makes sense in someone's mind

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          Not that I know of without executing it. If SQL Server, maybe check through the sqlcmd options.

          1 Reply Last reply
          0
          • K Kevin Marois

            It is possible to compile a SQL script via a command line?

            Everything makes sense in someone's mind

            B Offline
            B Offline
            Bernhard Hiller
            wrote on last edited by
            #5

            Do you think of "prepare"? In the .Net world, I use the prepare statement when I want to run the query repeatedly with different parameters. I do not know if that exists in the sql command line.

            P 1 Reply Last reply
            0
            • B Bernhard Hiller

              Do you think of "prepare"? In the .Net world, I use the prepare statement when I want to run the query repeatedly with different parameters. I do not know if that exists in the sql command line.

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #6

              Oh yeah, there's that, I never use it so I didn't think of it. A console app could be written to do it.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups