You can specify SQL Server Management Studio template parameters in SQL Prompt snippets.
In this example, we will create a snippet to select the following from a table:
To create the snippet:
Type or paste SQL code that includes template parameters in the Code box.
You specify template parameters using the format <parameter_name, data_type, value>. For more information, see Using SQL Server Management Studio Templates (Microsoft documentation).
In this example, we use the following snippet code:
SELECT 'Top <howmany,int,100> rows of ' + CONVERT(NVARCHAR(MAX), COUNT(*)) + ' in <table_name,sysname,MyTable>' AS Title FROM <table_name,sysname,MyTable>; SELECT TOP <howmany,int,100> * FROM <table_name,sysname,MyTable>; |
We can now insert the snippet into a query, and replace the template parameters with the values we want to use: