When writing SQL, I constantly find myself checking the structure of a table / view or selecting the top 100 rows to get a preview of the data.
For instance, when I have something like this (and I have forgotten the structure of table2)...
SELECT
FROM table1 INNER JOIN table2 ON table1.fieldX = table2.???
I would like to highlight a table / view name and then pass it to a SQL query by passing a parameter, say table2 to either of the following 2 queries
SELECT TOP 100 * FROM table2
or
SELECT o.Type, o.Type_Desc, o.name AS ObjectName, c.name AS ColumnName
FROM sys.objects AS o INNER JOIN sys.columns AS c ON o.object_id = c.object_id
WHERE o.name = N'table2' AND o.Type IN (N'U', N'V')
ORDER BY o.name,c.column_id,c.name
I use SSMS Boost (it's my favorite SSMS addin) but can't figure out how to use functionality (Auto Replacement, Shortcut, Macros) in order to accomplish what I want here.
Has anyone ever set this up?