Stored Proc Expansion
-
Greg Bacchus commented
This feature would also be useful for "flattening" nested stored procs.
-
Greg Bacchus commented
T-SQL debugger is not available on any of our servers because of network/firewall/security constraints and remote locations.
-
Damien Schoof commented
I would suggest that even implementing this the way RedGate does would be quite helpful. With Redgate SQL Prompt, when you click "Go To Definition" or press F12 with the caret in the name of a stored procedure, instead of just finding the SP in the object explorer, it will actually open a new tab, and paste the text of the the SP / function / View into that new tab.
T-SQL debugger is not always usable when working on a remote server or an older server.
-
AdminDevart (_, Devart) commented
We are forming the backlog for the next version release.
We are not sure about this feature.
Could you explain why you can't use T-SQL debugger? -
Greg Bacchus commented
One of the places where this is really useful is where you capture a query from SQL Server Profiler and you wish to debug it.
-
Greg Bacchus commented
And likewise it should work for literals, so:
DECLARE @MyInt INT
SELECT @MyInt = Age
FROM MyTable WHERE ID = 5EXEC MyTest @Age = @MyInt, @Surname = 'tom'
would become
DECLARE @MyInt INT
SELECT @MyInt = Age
FROM MyTable WHERE ID = 5SELECT * FROM MyTable mt
WHERE mt.Age = @MyInt AND mt.Surname = 'tom' -
Greg Bacchus commented
Ok, here is an example (even if it's a pretty contrived and benign one):
Given the following sproc existing in your databaseCREATE PROC MyTest
@Age INT,
@Surname VARCHAR(50)
AS
SELECT * FROM MyTable mt
WHERE mt.Age = @Age AND mt.Surname = @SurnameGO
And you are writing a query such as this:
DECLARE @MyInt INT,
@MyText VARCHAR(50)SELECT @MyInt = Age, @MyText = Surname
FROM MyTable WHERE ID = 5EXEC MyTest @Age = @MyInt, @Surname = @MyText
You right click on the "MyTest" in the query and choose "Expand". It then takes the contents of the sproc and substitutes it into your query, giving something like this.
DECLARE @MyInt INT,
@MyText VARCHAR(50)SELECT @MyInt = Age, @MyText = Surname
FROM MyTable WHERE ID = 5SELECT * FROM MyTable mt
WHERE mt.Age = @MyInt AND mt.Surname = @MyTextIt's a pretty pointless example, but I hope you get the purpose of it.
-
AdminDevart (_, Devart) commented
The suggestion is not quite clear for us. Could you please give us the code sample for the substitution?
-
Greg Bacchus commented
Oops... it posted it before I put in the details:
What I mean is: the coolest feature ever for debugging would be if you had a bit of code like:EXEC MySproc @param1='test', @param2=@something
and you hit "Expand", where it replaces the EXEC statement with the scripted body of the target stored proc, with all the arguments set as per the inputs.