Attach or Detach an Advance Steel database in SQL Server Management Studio

To view and edit the contents of an Advance Steel database, you first need to attach it in SQL Server Management Studio.

To view and edit the contents of an Advance Steel database, you first need to attach it in SQL Server Management Studio.

To attach an Advance Steel database:

  1. Start SQL Server Management Studio.
  2. Go to the Object Explorer menu, located in the left side of the window.
  3. Right-click on Databases and select Attach… from the contextual menu.
  4. In the Attach Databases window, click Add.
  5. Browse for the location of the database you want to open, select the database MDF file and click OK.
  6. The selected database will appear in the Object Explorer, under Databases.

Attach copies of Advance Steel databases

If you make a copy of an Advance Steel database in a different location on the disk and rename it, when you need to attach the copied database it is important you make some adjustments to be sure that the database copy is targeted.

After adding the copied database using the Add command, notice that the original database is still referenced:



This means that if you continue with the attachment process and you make changes in the database afterwards, the changes will be applied to both the original database and the copied database.

In order to make sure that the changes are made only to the copied database and not to the source database too, you need to make the following settings in the Attach Databases window:

The attachment process can be validated and the copied database will be available for editing in SQL Server Management Studio:



Important notes:

  • To make sure that the list of attached databases in the Object Explorer is up-to-date, right-click on the Databases category and select Refresh from the contextual menu.
  • If Advance Steel or Management Tools are started, all the Advance Steel databases are automatically connected and attached to the SQL instance and they will be automatically visible in the Object Explorer list:


To detach a database from SQL Management Studio (remove it from the Databases list), right-click to select the database and select Tasks Detach… from the contextual menu. To finish detaching the database, confirm by clicking OK in the window that pops up.

Important: Do not use Delete instead of Detach, because this will remove the database from the disk.

Detach bulk databases from a LocalDB instance

Every time an application uses a MDF database, the SQL LocalDB will remember that connection in order to optimize future access to it.

In case the number of attached databases in the LocalDB increases, performance might be slower than expected. To improve this, you can manually detach all the attached databases, using the following query:

DECLARE @dbname AS VARCHAR(MAX);
DECLARE @server_name AS VARCHAR(MAX);
SELECT @server_name = @@servername
DECLARE rs_cursor CURSOR FOR SELECT name FROM master.dbo.sysdatabases WHERE name NOT IN ('model', 'master', 'msdb', 'tempdb', 'alert_db', 'mssecurity');
	OPEN rs_cursor;
	FETCH NEXT FROM rs_cursor INTO @dbname;
	WHILE @@FETCH_STATUS = 0
		BEGIN
		EXEC sp_detach_db @dbname;
		PRINT 'Detach of "' + upper(@dbname) + '" database successfully completed.';
		FETCH NEXT FROM rs_cursor INTO @dbname;
		END
	CLOSE rs_cursor;
DEALLOCATE rs_cursor;
PRINT CHAR(13) + 'All databases successfully detached from: ' + upper(@server_name);
Important: Be aware that this query will detach all the attached databases and this action might affect other software that are using that SQL LocalDB instance. When running this query, close all programs using databases. If you need assistance with this issue, please contact the IT department of your company before attempting to run this query.