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.
You can use different syntax to achieve different things. If it is windows authentication you want, you could try this:
sqlcmd /S /d -E
If you want to use SQL Server authentication you could try this:
sqlcmd /S /d -U -P
Definitions:
/S = the servername/instance name. Example: Pete's Laptop/SQLSERV
/d = the database name. Example: Botlek1
-E = Windows authentication.
-U = SQL Server authentication/user. Example: Pete
-P = password that belongs to the user. Example: 1234
Hope this helps!
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With