範本總管Template Explorer

SQL ServerSQL Server 提供各種範本。 provides a variety of templates. 範本為包含 SQL 指令碼的模板檔案,可協助您在資料庫中建立物件。Templates are boilerplate files containing SQL scripts that help you create objects in a database. 第一次開啟範本總管時,範本的複本是放置在 C:\Users 使用者資料夾的 AppData\Roaming\Microsoft\SQL Server Management Studio\130\Templates 底下。The first time the template explorer is opened, a copy of the templates are placed in the user’s folder in C:\Users, under AppData\Roaming\Microsoft\SQL Server Management Studio\130\Templates.

您可以在 [範本總管] 中瀏覽可用的範本,然後開啟範本以將程式碼併入程式碼編輯器視窗。You can browse the available templates in Template Explorer, then open a template to incorporate the code into a code editor window. 您還可以建立自訂範本。You can also create custom templates.

範本的優點Benefits of Templates

方案、專案和各類型的程式碼編輯器都可以使用範本。Templates are available for solutions, projects, and various types of code editors. 您可以利用範本來建立資料庫、資料表、檢視、索引、預存程序、觸發程序、統計資料和函數這類物件。Templates are available to create objects like databases, tables, views, indexes, stored procedures, triggers, statistics, and functions. 此外,還有一些範本可協助您建立 Analysis ServicesAnalysis Services的擴充屬性、連結伺服器、登入、角色、使用者和範本來管理伺服器。In addition, there are templates that help you to manage your server by creating extended properties, linked servers, logins, roles, users, and templates for Analysis ServicesAnalysis Services.

Transact-SQLSQL Server Management Studio 所提供的範本指令碼包含協助您自訂程式碼的參數。The template scripts provided with Transact-SQLSQL Server Management Studio contain parameters to help you customize the code. 開啟範本時,請使用 [取代範本參數] 對話方塊,在指令碼中插入值。When you open a template, Use the Replace Template Parameters dialog box to insert values into the script.

請建立您經常執行之工作的自訂範本。Create custom templates for tasks you perform frequently. 請將您的自訂指令碼組織成現有的資料夾,或建立新的資料夾結構。Organize your custom scripts into the existing folders or create a new folder structure.

Database EngineDatabase Engine 查詢編輯器也支援程式碼片段,可透過以滑鼠右鍵按一下指令碼中的特定位置,在該位置插入程式碼片段。The Database EngineDatabase Engine Query editor also supports code snippets, which can be inserted at specific locations in a script by right-clicking at that location.

若要開始使用範本,請使用下列主題。Use the following topics to get started with templates

說明Description 主題Topic
描述如何將範本中的程式碼併入至程式碼編輯器視窗。Describes how to incorporate the code from a template into a code editor window. 開啟範本Open a Template
描述在程式碼編輯器中開啟範本後如何取代範本參數值。Describes how to replace template parameter values after opening a template in a code editor. 取代範本參數Replace Template Parameters