Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
dirtyfishtank
Starting Member
8 Posts |
Posted - 2012-01-03 : 06:03:20
|
Hi all.I have installed a sample database called 'books' running on MS Server Management studio express on my personal pc. The database works fine, however I would like to be able to run scripts thru a cmd prompt using sqlcmd. I am the administrator and owner of the server, computer and the db, but when I run sqlcmd -d books I get this error: Msg 4060, Level 11, State 1, Server MYNAME-PC, Line 1Cannot open database "books" requested by the login. The login failed.When I use this command sqlcmd -d books -U <username> I get prompted the password but gives me the error: Msg 4060, Level 11, State 1, Server MYNAME-PC, Line 1Cannot open database "books" requested by the login. The login failed.This happens even when I run cmd as administrator. I set up the database to use windows authentication. I'm not sure I chose a password for server authentication. Is there an easy fix for this? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-01-03 : 06:21:10
|
| you're running sqlcmd under your admin windows account?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
dirtyfishtank
Starting Member
8 Posts |
Posted - 2012-01-03 : 06:50:12
|
| yes I am. Is there a way to recover the sql server password? Could that be what is causing the problem? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-01-03 : 07:33:33
|
| hmm..which sql server password? you're using trusted connection right?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-01-03 : 07:54:45
|
If you are using SQLExpress, the server name would be MYNAME-PC\SQLExpress. So try:sqlcmd -d books -S MYNAME-PC\SQLExpress |
 |
|
|
dirtyfishtank
Starting Member
8 Posts |
Posted - 2012-01-03 : 08:07:11
|
| That works. Thanks! |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|
|
|