views:

88

answers:

2

Have a SQL Server 2008 db which I connect to the Windows Authentication .. has worked good for 7-8 months .. but now when I come to work today it no longer worked to connect, without that I had done something Error message was:

Can not open user default database. Login failed. Login failed for user 'Jimmy-PC \ Jimmy'.

where the first is the computer name and the second is the user. The problem seems to be that it tries to connect to the default database. Have tried to change it without success .. I do not have sql server management tools for sql 2008 but only to 2005, someone who has similar experience? who have not touched anything said over the weekend and it worked last Friday without any problems.

A: 

It is strange that it just stopped working. Have you checked the status of the user's default database? Make sure the database exists and is online.

To find the user's default database run the following command using sqlcmd.exe

select dbname from syslogins where name = 'Jimmy-PC \ Jimmy'

I have seen this error when recovering a system and the user's default database hadn't been restored yet and another time when a database was in "Recovery" mode.

I would also make sure that the windows account is not disabled.

If you find that you need to change the user's default database you can use a T-SQL command, see the following question:

http://stackoverflow.com/questions/105950/how-do-i-set-the-default-database-in-sql-server-from-code

Marc Tidd
first of all, what database if the default one? and also.. i cannot connect to any database using sql server management tool. It says it only handles 2000 and 2005 databases.. and i couldnt find how to do it simular in the 2008 version... I dont use any login to windows i only have 1 account therefore it shouldnt be that
Jimmy
@Jimmy, I have added the sql to my answer to find the user's default database. Once you find the user's default database follow @Remus Rusanu's advice to determine the database status.
Marc Tidd
A: 

The user's default database is offline. the thing that changed since yesterday is that your database had failed, for whatever reason.

You need to log in with a different account, one that does not have a default database, and inspect the state of the database. If you do not have such an account, then you can use an administrator account. If the administrators group is not granted login into SQL Server then see this article Troubleshooting: Connecting to SQL Server When System Administrators Are Locked Out.

Once you can log in, the only tool you need is sqlcmd.exe, which is installed on your machine. Look into sys.databases, the state_desc column will tell if a database is offline. You can try a to ALTER DATABASE ... SET ONLINE and see if it recovers, but that would be unlikely. Your best choice will be to apply your disaster recovery plan and restore the database from the backups you keep for it.

Remus Rusanu
I cant access any accounts and i only think i have 1... maybe if i make a new account from sqlcmd, but i have no idea how to do that.also.. i cannot manage my db with my sql server management tools bcuz they are for sql server 2005 and earlier.. couldnt find the proper tolls for 2008... deleted the database from its directory and put in a backup.. but the problem persists.
Jimmy