How can I connect to SQL Server from command prompt using Windows authentication?
This command
Sqlcmd -u username -p password
assumes a username & password for the SQL Server already setup
Alternatively how can I setup a user account from command prompt?
I've SQL Server 2008 Express on a Windows Server 2008 machine, if that relates.
This question is related to
sql
sql-server
sql-server-2008
command-prompt
here is the commend which is tested Sqlcmd -E -S "server name" -d "DB name" -i "SQL file path"
-E stand for windows trusted
Try This :
--Default Instance
SQLCMD -S SERVERNAME -E
--OR
--Named Instance
SQLCMD -S SERVERNAME\INSTANCENAME -E
--OR
SQLCMD -S SERVERNAME\INSTANCENAME,1919 -E
More details can be found here
This might help..!!!
SQLCMD -S SERVERNAME -E
After some tries, these are the samples I am using in order to connect:
Specifying the username and the password:
sqlcmd -S 211.11.111.111 -U NotSA -P NotTheSaPassword
Specifying the DB as well:
sqlcmd -S 211.11.111.111 -d SomeSpecificDatabase -U NotSA -P NotTheSaPassword
type sqlplus/"as sysdba" in cmd for connection in cmd prompt
Source: Stackoverflow.com