SQL Server 2005 Express Database-Level Statements
If you need to perform statements at the database level for a SQL Server 2005 Express database, what do you do? With an attached database, you can reference it by name, but Express databases aren't necessarily attached, so in a detached state, how do you handle this? The full path to the file is acceptable to reference it. Consider the following command:
backup log [C:\DOCUMENTS AND SETTINGS\BRIAN\MY DOCUMENTS\VISUAL STUDIO 2005\PROJECTS\RELIGION.NET\RELIGION\RELIGION.MDF] with truncate_only;
Make sure that you enclose the name with [] for it to work. This will reference the detached database successfully.