debugsqlMajor
Cannot get SQLCMD to work regardless of what I try
Viewed 0 times
cannotwhatregardlessgetworksqlcmdtry
Problem
Regardless of what I do, I cannot get SQLCMD to work. I am trying to run a script that is 200mb+ in size and cannot be run from the sql server application so I need to do this via SQLCMD, however whenever I try to login or run the script it immediately closes.
I've followed the sqlcmd utility by msdn.
I've tried to opoen it via trusted command SQLCMD -E
I get:
I've tried via explicit server, username and password declaration:
I've followed the sqlcmd utility by msdn.
I've tried to opoen it via trusted command SQLCMD -E
I get:
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Named Pipes Provider: Could not open a connection to SQL Server [2]. .
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login timeout expired.
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..I've tried via explicit server, username and password declaration:
C:\Users\MyUserName\Documents>SQLCMD -S DESKTOP-1N3OD6V\SQLEXPRESS -U DESKTOP-1N3OD6V\MyUserName-P MyPassword
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login failed for user 'DESKTOP-1N3OD6V\MyUserName'..Solution
SQLCMD, when invoked without specifying a server name, tries to connect to a default instance on the local machine. If you don't have one, it displays the first error you are getting. Use the -S parameter to specify a server name. To use Windows authentication, use the
-E flag and you don't need to provide username or password. Example: SQLCMD -Smyserver\myinstance -ETo use SQL Server authentication, use the
-U and -P parameters to supply credentials. Example: SQLCMD -Smyserver\myinstance -UsomeUser -PhisPasswordIf you specify
-U you cannot use a windows user name: this is for SQL Server logins. If you want to impersonate a different windows user, start a command prompt impersonating that user first.Example:
- Open command prompt
- Type
runas /USER:domain\username cmd
- Type the password for your user
- Run
SQLCMD
You can achieve the same result right clicking the link for cmd and selecting "Run as different user..."
Context
StackExchange Database Administrators Q#120511, answer score: 26
Revisions (0)
No revisions yet.