This article will give you an Overview of Template Explorer Feature in SQL Server Management Studio which was initially introduced in SQL Server 2005. SSMS has a variety of inbuilt templates which contains SQL Scripts that can help you create objects within SQL Server Database.
Let’s work through an example of using the Template Explorer feature in SSMS to Attach a database.
1. Open SSMS and connect to a SQL Server Instance.
2. Click the View > Template Explorer option from the drop down menu as shown in the below screenshot to open Template Explorer on the right side of SSMS.
3. In Template Explorer expand SQL Server Templates > Database and double click Attach Database to open the TSQL Script in a new query window to attach database in SQL Server.
4. Once the TSQL Code to attach the database is open in SSMS, you can go ahead and make the required changes to the TSQL code directly or you can click Query > Specify Values for Template Parameters… to pass values to the template as shown in the screenshot below.
5. In the Specify Values for Template Parameters dialog box enter the values for database name and database primary file path as shown in the below screenshot and click OK to replace the values within the TSQL script template.
6. In the below screenshot you could see that the values were replaced with the values provided in the Specify Values for Template Parameters dialog box.
7. Finally, execute the TSQL code to successfully attach the SQL Server Database to your SQL Server Instance.
8. Note from the below screenshot the database was successfully attached and it is available for user connections.
]]>