iA


SQL Server madness

by Vijay Kiran

So, I got this MDF fie from some one who has MS SQL Server 2005. They created the log file (LDF) and the database file (MDF).

I’ve installed SQL Server 2005 Express edition. I used SQL Server Management studio express to attach the database. The attach went fine, but the it says the Database is Read-Only. I tried ALTER DATABASE to modify the permission. It says can’t read the MDF file, access denied. So I dig down the file, and tried looking at the properties. It has the READ ONLY un-checked! I can’t understand why the hell is the database is read-only.

I used osql command line to attach the database with FOR ATTACH as well as FOR ATTACH_REBUILD_LOGS, but still it says the database readonly. I googled 10 times searching for how to make this damn thing writable, since I needed that to test my program. It took 2 hours after digging through MSDN that the guy who’s attaching the MDF to the database to the MDF has to have Write permission on the DB. What the #$%@@##?????

I enabled the Windows authentication on the SQL Server Express 2005, and then logged in as the admin guy. And attached the DB to the Server. Voila! It’s a miracle. Now I re-login to the server using the SQL Server authentication. The DB is still writable. For my primitive mind at least this looked like the dumbest thing I’ve ever heard. You have write permission, and you attach the DB, and any the other can access it with write permission too .. ! May be I’m too dumb to understand MS Software, that’s why I prefer sticking with Mac/Java/Open Source.

Ignorance is Bliss!, especially its MS’s Stuff.