How to connect to SQL Server from command prompt with Windows authentication

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 <br/>

--OR
--Named Instance

SQLCMD -S SERVERNAMEINSTANCENAME -E <br/>

--OR

SQLCMD -S SERVERNAMEINSTANCENAME,1919 -E

More details can be found here


这可能会有所帮助.. !!!

 SQLCMD -S SERVERNAME -E 
链接地址: http://www.djcxy.com/p/7730.html

上一篇: 基于SQL Server的身份验证

下一篇: 如何使用Windows身份验证从命令提示符连接到SQL Server