Retatching a Database

  • I was trying to copy one to database to another server and I detached the database to copy it and closed the Enterprise Manager. Now I can't get back into the SQL Server Group because I think the database I detached was the default database and I get an error message saying "Cannot open user default database. Login failed." Is there a way to fix this?

  • Have the sysadmin sign in using 'sa' and either re-attach your DB, or reassign your default DB.  Hopefully you were not using 'sa' already.

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • I tried that and I'm getting this error:

    C:\Documents and Settings\administrator.FLORIDAFOOD.000>osql -U sa -S ffs2000a\bkupexec

    Password:

    Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

  • That means your SQL Server is in Windows authentication only mode (not mixed mode). You can make a registry setting change to switch it to mixed mode and restart SQL Server, but that assumes you know the sa password. Does anyone else have sysadmin rights to SQL Server? By default, BUILTIN\Administrators aka the computer's Administrators group, has sysadmin rights if this helps any. If someone can log in with that level of privileges that person can change the default database.

    K. Brian Kelley
    @kbriankelley

  • You can run the osql command with trusted authentication and change the default database if you have sufficient rights.  When you run osql, it doesn't validate the default database.  Run the command directly against the master database.

    Derrick Leggett
    Mean Old DBA
    When life gives you a lemon, fire the DBA.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply