Could not find entry in sysdatabases for database 'mydb'

I had SQL Server 2005 on my computer and created several databases through it. Due to some problems, I had to reinstall it, but now when I give the command "create mydb database", it says

"Cannot create file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\myDb.mdf' because it already exists. Change the file path or the file name, and retry the operation."

And when I give the command "use mydb", it says

Could not locate entry in sysdatabases for database 'mydb'. No entry found with that name. Make sure that the name is entered correctly.

What should I do to find my databases?

+3
source share
3 answers

You can reattach the database files (assuming that your current installation has at least the same service pack / patch level as before).

You can attach the database using Management Studio or using CREATE DATABASE

+2
source

, , .

C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\ myDB.mdf .ldf, .

0

I ran into the same problem.

We need to use square brackets for the database name

t

use [database]

instead

use database

Hope this helps.

0
source

All Articles