I had SQL Server 2005 on my pc and had created a few databases through it. Due to some problem, I had to reinstall it but now when i give the command "create database mydb" 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 "use mydb" command 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 so that it can locate my databases?
I faced the same issue.
We need to use Square brackets for database name
ie
use [database]
instead of
use database
Hope it helps.
You can re-attach the database files (assuming that your current installation is at at least the same service pack/patch level as you previously had it).
You can attach the database using either Management Studio, or using CREATE DATABASE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With