Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 44434

SQLCMD is Microsoft SQL Server's command line utility that allows you execute T-SQL commands from a command prompt.

3 votes

SQLCMD external editor

This looks like a SQLCMD bug. I can repro with SQLCMD 14.0.3026.27 on Windows 10. I submitted the bug report on the SQL Server feedback site. Consider upvoting the bug report. …
Dan Guzman's user avatar
  • 28.5k
2 votes
Accepted

How can I mask a CMD-Variable reference $(myVar)?

See https://msdn.microsoft.com/en-us/library/ms162773.aspx SQLCMD for syntax. EDIT: Note that there are two parsers involved here, SQLCMD and T-SQL. … Double quote enclosures are required for SQLCMD variable values when the value contains a space or a double quote. …
Dan Guzman's user avatar
  • 28.5k
2 votes

SQLCMD :CONNECT with a specific port?

Yes, you can specify a port number as in your example (but with no space): :CONNECT MySQLServer,49603
Dan Guzman's user avatar
  • 28.5k
2 votes

How do I stop SQLCMD from misinterpreting variable parameters?

Maybe someone can suggest a better method as this seems a kludge but instead of :r, you could shell out to another SQLCMD session: ::sqlcmd -i \\folder\path\script.sql -x -I Also added -I for QUOTED IDENTIFIERS …
Dan Guzman's user avatar
  • 28.5k
1 vote
Accepted

Does SQLCMD "!!" command work in Azure Data Studio

This is a known open issue with SQLCMD in ADS, where SQLCMD mode fails to parse some sqlcmd keywords. The issue is currently on the backlog. … ADS includes a terminal window (View-->Terminal) so you can easily run OS commands on your client under the same query tab without SQLCMD. …
Dan Guzman's user avatar
  • 28.5k
4 votes

How can I increase the length of the string returned by object_definition in sqlcmd?

Specify the -y SQLCMD option to avoid truncating the value to the 256 character default. -y0 will not truncate the value but should be used with caution as mentioned in the doc. … Example: sqlcmd -i extract.sql -y0 -o %oudir%\extracted.dat …
Dan Guzman's user avatar
  • 28.5k
11 votes
Accepted

sqlcmd -b doesn't exit on error

Remember that SQLCMD sends the entire batch of statements at once to SQL Server for execution. …
Dan Guzman's user avatar
  • 28.5k
1 vote

Check if a SQL Login exists without SA

SQL Server will allow you to create a database user for a domain account, even if the corresponding login does not exist. No error will be returned as long as the user creating the database user has C …
Dan Guzman's user avatar
  • 28.5k
3 votes
Accepted

SSMS generated script failing to execute

Try running SQLCMD with the -x argument to disable variable substation. This will avoid issues when the script includes SQLCMD variable tokens (e.g. … $(stuff-here)) but are not actually SQLCMD variables. …
Dan Guzman's user avatar
  • 28.5k
4 votes

How to format the output of SQL queries on SQLCMD for SQL Server 2017 on RHEL Linux 7.3?

The sqlcmd utility is handy for executing T-SQL scripts via command-line, such as in automation scenarios, but is limited in its output formatting capabilities and interactive query editor. …
Dan Guzman's user avatar
  • 28.5k