Sqlcmd don't work

Arthur Tagirov's Avatar

Arthur Tagirov

01 Apr, 2015 07:53 PM

I have problem with using mssql. I want create new Database with'Reconciliation' name on SQL server.

Part of my appveyor:

services:
  - mssql2012sp1
  
before_build:
  - sqlcmd -?
  - sqlcmd –L
  - sqlcmd -b -E –S "(local)\SQL2008R2SP2" -Q "CREATE DATABASE Reconciliation"

Displayed in logs for Failed build (part):

Starting SQL Server 2012 SP1 Express
Waiting for service 'SQL Server (SQL2012SP1) (MSSQL$SQL2012SP1)' to start...
sqlcmd -?
Microsoft (R) SQL Server Command Line Tool
Version 11.0.2100.60 NT x64
Copyright (c) 2012 Microsoft. 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 <codepage> | i:<codepage>[,o:<codepage>]] [-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]
  [-K application intent]
  [-M multisubnet failover]
  [-b On error batch abort]
  [-v var = "value"...] [-A dedicated admin connection]
  [-X[1] disable commands, startup script, environment variables [and exit]]
  [-x disable variable substitution]
  [-? show syntax summary]
sqlcmd –L
Sqlcmd: '–L': Unknown Option. Enter '-?' for help.
Command exited with code 1

Sometimes -L command is successfull work, but next command failed with

Sqlcmd: '–S': Unknown Option. Enter '-?' for help.

message

  1. 1 Posted by Arthur Tagirov on 01 Apr, 2015 07:57 PM

    Arthur Tagirov's Avatar

    instead:
      - sqlcmd -b -E –S "(local)\SQL2008R2SP2" -Q "CREATE DATABASE Reconciliation"

    i am also using:
      - sqlcmd -b -E –S "(local)\SQL2012SP1" -Q "CREATE DATABASE Reconciliation"

    no changes

  2. Support Staff 2 Posted by Feodor Fitsner on 01 Apr, 2015 08:43 PM

    Feodor Fitsner's Avatar

    There is a typo in your command: S parameter with a long dash . The following command works for mssql2012sp1 service:

    - sqlcmd -b -E -S "(local)\SQL2012SP1" -Q "CREATE DATABASE Reconciliation"
    
  3. 3 Posted by Arthur Tagirov on 01 Apr, 2015 09:30 PM

    Arthur Tagirov's Avatar

    Thank's, "copy paste error" )

  4. 4 Posted by Hany on 30 Jul, 2018 08:11 AM

    Hany's Avatar

    Hi,

    I am using SQL Server 2014 SP2 with AG, running this command:

    sqlcmd -S ABC-ISELL -E -d ABP_SFA_BMB -K ReadOnly

    Where ABC-ISELL is the listener name , getting this error:

    Sqlcmd: 'KReadOnly': Unknown Option. Enter '-?' for help.

    Even more in sqlcmd -? There is no -K option, it`s just this:

    [-k[1|2] remove[replace] control characters]

    What could be wrong here?!

    Best Regards,
    Hany Helmy

  5. Support Staff 5 Posted by Ilya Finkelshte... on 30 Jul, 2018 08:59 AM

    Ilya Finkelshteyn's Avatar

    @Hany: please share full build configuration in YAML format (use Export YAML menu if you use UI).

  6. Ilya Finkelshteyn closed this discussion on 29 Sep, 2018 09:00 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

23 Oct, 2018 10:37 PM
23 Oct, 2018 08:45 PM
23 Oct, 2018 07:48 PM
23 Oct, 2018 06:50 PM
23 Oct, 2018 06:06 PM