Download Microsoft SQL Server 2005 Command Line Query Utility

1 view
Skip to first unread message

Nadia Grubb

unread,
May 20, 2024, 7:00:21 PM5/20/24
to daylamhisimp

While Microsoft Entra ID is the new name for Azure Active Directory (Azure AD), to prevent disrupting existing environments, Azure AD still remains in some hardcoded elements such as UI fields, connection providers, error codes, and cmdlets. In this article, the two names are interchangeable.

download Microsoft SQL Server 2005 Command Line Query Utility


Download Zip »»» https://t.co/QupwDh7zlU



This content references CentOS, a Linux distribution that is nearing End Of Life (EOL) status. Please consider your use and plan accordingly. For more information, see the CentOS End Of Life guidance.

Download the repository configuration file, where the centos/8 segment may be centos/8, fedora/32, opensuse/42.3, rhel/8, or sles/15. If the version of your OS doesn't directly correspond to one of those options, you can likely successfully use a repository configuration file from a version. For example, centos/8 can be used in an environment running CentOS 7.

The sqlcmd download provided here might not have the same release and build number as sqlcmd installed with the latest SQL Server cumulative update (CU). This is expected behavior. This version contains all the fixes included in the latest CU.

sqlcmd (ODBC) supports authentication with Microsoft Entra ID (formerly Azure Active Directory), including multifactor authentication (MFA) support for Azure SQL Database, Azure Synapse Analytics, and Always Encrypted features.

SSMS uses the Microsoft .NET Framework SqlClient for execution in regular and SQLCMD mode in Query Editor. When sqlcmd is run from the command-line, sqlcmd uses the ODBC driver. Because different default options may apply, you might see different behavior when you execute the same query in SSMS in SQLCMD Mode and in the sqlcmd utility.

Several switches and behaviors are altered in the sqlcmd (Go) utility. For the most up-to-date list of missing flags for backward compatibility, visit the Prioritize implementation of back-compat flags GitHub discussion.

All commands must fit on one line, even EXIT. Interactive mode doesn't check for open parentheses or quotes for commands, and doesn't prompt for successive lines. This behavior is different to the ODBC version, which allows the query run by EXIT(query) to span multiple lines.

:Connect now has an optional -G parameter to select one of the authentication methods for Azure SQL Database - SqlAuthentication, ActiveDirectoryDefault, ActiveDirectoryIntegrated, ActiveDirectoryServicePrincipal, ActiveDirectoryManagedIdentity, ActiveDirectoryPassword. For more information, see Microsoft Entra authentication. If -G isn't provided, Integrated security or SQL Server authentication is used, depending on the presence of a -U user name parameter.

Currently, sqlcmd doesn't require a space between the command-line option and the value. However, in a future release, a space may be required between the command-line option and the value.

Signs in to SQL Server with a dedicated administrator connection (DAC). This kind of connection is used to troubleshoot a server. This connection works only with server computers that support DAC. If DAC isn't available, sqlcmd generates an error message, and then exits. For more information about DAC, see Diagnostic Connection for Database Administrators. The -A option isn't supported with the -G option. When connecting to Azure SQL Database using -A, you must be an administrator on the logical SQL server. DAC isn't available for a Microsoft Entra administrator.

Issues a USE statement when you start sqlcmd. This option sets the sqlcmd scripting variable SQLCMDDBNAME. This parameter specifies the initial database. The default is your login's default-database property. If the database doesn't exist, an error message is generated and sqlcmd exits.

Specifies the number of seconds before a sqlcmd login to the ODBC driver times out when you try to connect to a server. This option sets the sqlcmd scripting variable SQLCMDLOGINTIMEOUT. The default time-out for login to sqlcmd is 8 seconds. When using the -G option to connect to Azure SQL Database or Azure Synapse Analytics and authenticate using Microsoft Entra ID, a timeout value of at least 30 seconds is recommended. The login time-out must be a number between 0 and 65534. If the value supplied isn't numeric, or doesn't fall into that range, sqlcmd generates an error message. A value of 0 specifies time-out to be infinite.

The -E option ignores possible user name and password environment variable settings such as SQLCMDPASSWORD. If the -E option is used together with the -U option or the -P option, an error message is generated.

Sets the Column Encryption setting to Enabled. For more information, see Always Encrypted. Only master keys stored in Windows Certificate Store are supported. The -g option requires at least sqlcmd version 13.1. To determine your version, execute sqlcmd -?.

This option is used by the client when connecting to Azure SQL Database or Azure Synapse Analytics to specify that the user be authenticated using Microsoft Entra authentication. This option sets the sqlcmd scripting variable SQLCMDUSEAAD = true. The -G option requires at least sqlcmd version 13.1. To determine your version, execute sqlcmd -?. For more information, see Connecting to SQL Database or Azure Synapse Analytics By Using Microsoft Entra authentication. The -A option isn't supported with the -G option.

Microsoft Entra interactive authentication isn't currently supported on Linux or macOS. Microsoft Entra integrated authentication requires Microsoft ODBC Driver 17 for SQL Server version 17.6.1 or higher and a properly Configured Kerberos environment.

A workstation name. This option sets the sqlcmd scripting variable SQLCMDWORKSTATION. The workstation name is listed in the hostname column of the sys.sysprocesses catalog view, and can be returned using the stored procedure sp_who. If this option isn't specified, the default is the current computer name. This name can be used to identify different sqlcmd sessions.

Declares the application workload type when connecting to a server. The only currently supported value is ReadOnly. If -K isn't specified, sqlcmd doesn't support connectivity to a secondary replica in an availability group. For more information, see Active Secondaries: Readable Secondary Replica (Always On Availability Groups).

Always specify -M when connecting to the availability group listener of a SQL Server availability group or a SQL Server Failover Cluster Instance. -M provides for faster detection of and connection to the (currently) active server. If -M isn't specified, -M is off. For more information about Listeners, Client Connectivity, Application Failover, Creation and Configuration of Availability Groups (SQL Server), Failover Clustering and Always On Availability Groups (SQL Server), and Active Secondaries: Readable Secondary Replicas(Always On Availability Groups).

A user-specified password. Passwords are case-sensitive. If the -U option is used and the -P option isn't used, and the SQLCMDPASSWORD environment variable hasn't been set, sqlcmd prompts the user for a password. We don't recommend the use of a null (blank) password, but you can specify the null password by using a pair of contiguous double-quotation marks for the parameter value ("").

Using -P should be considered insecure. Avoid giving the password on the command line. Alternatively, use the SQLCMDPASSWORD environment variable, or interactively input the password by omitting the -P option.

The SQLCMDPASSWORD environment variable lets you set a default password for the current session. Therefore, passwords don't have to be hard-coded into batch files. The following example first sets the SQLCMDPASSWORD variable at the command prompt and then accesses the sqlcmd utility.

The OSQLPASSWORD environment variable has been kept for backward compatibility. The SQLCMDPASSWORD environment variable takes precedence over the OSQLPASSWORD environment variable. This means that sqlcmd and osql can be used next to each other without interference. Old scripts will continue to work.

Specify server_name to connect to the default instance of SQL Server on that server computer. Specify server_name[\instance_name] to connect to a named instance of SQL Server on that server computer. If no server computer is specified, sqlcmd connects to the default instance of SQL Server on the local computer. This option is required when you execute sqlcmd from a remote computer on the network.

The OSQLSERVER environment variable has been kept for backward compatibility. The SQLCMDSERVER environment variable takes precedence over the OSQLSERVER environment variable. This means that sqlcmd and osql can be used next to each other without interference. Old scripts will continue to work.

The OSQLUSER environment variable has been kept for backward compatibility. The SQLCMDUSER environment variable takes precedence over the OSQLUSER environment variable. This means that sqlcmd and osql can be used next to each other without interference. Old scripts will continue to work.

If you don't specify either the -U option or the -P option, sqlcmd tries to connect by using Windows Authentication mode. Authentication is based on the Windows account of the user who is running sqlcmd.

dd60e6d636
Reply all
Reply to author
Forward
0 new messages