Yes! It would be really great if we could convert a normal SQL into a dynamic SQL to pass different variables in parameters.
Ex:
SELECT p.Id FROM MyStore..Product AS p
LEFT JOIN OtherDatabase..Specs AS s on s.Id = p.Id
WHERE
p.Deleted = 0 AND
s.Color = 'Blue'
Once selected and converted using the new SQL Prompt shortcut, would become :
DECLARE @SQL NVARCHAR(MAX)
SELECT @SQL = N'SELECT p.Id FROM MyStore..Product AS p' +
N'LEFT JOIN OtherDatabase..Specs AS s on s.Id = p.Id' +
N'WHERE ' +
N'p.Deleted = 0 AND' +
N's.Color = ''Blue'' '
while converting single quote in double quotes '' and while keeping the code alignment provided by the "Format SQL" command.
I know it would be a HUGE asset and would save a lot of people lots of time formatting it by hand, since this is the only way of passing a Database name by parameter to a Stored Procedure in T-SQL.
Yes! It would be really great if we could convert a normal SQL into a dynamic SQL to pass different variables in parameters.
Ex:
SELECT p.Id FROM MyStore..Product AS p
LEFT JOIN OtherDatabase..Specs AS s on s.Id = p.Id
WHERE
p.Deleted = 0 AND
s.Color = 'Blue'
Once selected and converted using the new SQL Prompt shortcut, would become :
DECLARE @SQL NVARCHAR(MAX)
SELECT @SQL = N'SELECT p.Id FROM MyStore..Product AS p' +
N'LEFT JOIN OtherDatabase..Specs AS s on s.Id = p.Id' +
N'WHERE ' +
N'p.Deleted = 0 AND' +
N's.Color = ''Blue'' '
while converting single quote in double quotes '' and while keeping the code alignment provided by the "Format SQL" command.
I know it would be a HUGE asset and would save a lot of people lots of time formatting it by hand, since this is the only way of passing a Database name by parameter to a Stored Procedure in T-SQL.
Thanks!