At home, I have SQL Server 2008 R2 (Express) installed which is attached to a certain .mdf file. I\'m in the process of installing SQL Server 2012 (Developer Edition). Can I att
It might work - but I believe you're going run in to some issues later down the road if the SQL 2012 updates the file in a technical manner that SQL 2008 blows up on.
Wouldn't it be simpler to run one copy and back up and restore to the other?
You can go upwards - from an older version to a newer one, e.g. you can backup your database in 2008 R2 and restore that backup in your 2012 instance - but you CANNOT attach/detach or backup/restore a database from a newer version of SQL Server down to an older version - the internal file structures are just too different to support backwards compatibility.
Also: since the internal file structures of the .mdf
are very much different and specific to each version of SQL Server, you will NOT be able to use the same .mdf
from two different SQL Server versions. That definitely won't work.
You can either get around this problem by
using the same version of SQL Server on all your machines - then you can easily backup/restore databases between instances
otherwise you can create the database scripts for both structure (tables, view, stored procedures etc.) and for contents (the actual data contained in the tables) either in SQL Server Management Studio (Tasks > Generate Scripts
) or using a third-party tool
or you can use a third-party tool like Red-Gate's SQL Compare and SQL Data Compare to do "diffing" between your source and target, generate update scripts from those differences, and then execute those scripts on the target platform; this works across different SQL Server versions.