| Author |
Message |
blackshirt
Joined: 26 Oct 2010 Posts: 2
|
Posted: Tue Oct 26, 2010 9:14 pm Post subject: Unused Params & Variables |
|
|
In SSMS I generated a script of all my SPs on the database. I then brought that script in and highlighted them all then selected SQL Refactor -> Find Unused Variables and Parameters........I get an error message saying it cant highlight some variables because of some syntax errors while being parsed. So then I started from beginning and highlighted SP1 and no issues. Then highlighted SP1 and SP2.....again no issues.....then I did SP1, SP2, and SP3 then got the error....so I just highlighted SP3 and again no issues.....so is there a limit, buffer limit, or something wrong with trying to do this against multiple SP's in your database?
My main goal is to try to run this utility against all my SP's in my DB and not just one by one which would take forever.
thanks |
|
| Back to top |
|
 |
Anu Deshpande
Joined: 20 Apr 2009 Posts: 595 Location: Cambridge
|
Posted: Thu Oct 28, 2010 3:12 pm Post subject: |
|
|
Many thanks for your post and apologies for inconvenience caused.
Are you able to parse the same multiple SP query through management Studio 'Parse' functionality?
As when I open multiple SP's in one Query Window and first parse it it gives me error: "Msg 154, Level 15, State 1, Procedure spArtikelBuchung, Line 240
a USE database statement is not allowed in a procedure, function or trigger."
But SQL Refactor do the job for me.
Kindly let me know the detailed version of SQL Refactor you have installed on your machine.
You can know the detailed version of SQL Refactor by navigating to SQL Refactor --> About SQL Refactor and version number is displayed on bottom right. _________________ Anuradha Deshpande
Product Support
Redgate Software Ltd.
E-mail: support@red-gate.com |
|
| Back to top |
|
 |
blackshirt
Joined: 26 Oct 2010 Posts: 2
|
Posted: Thu Oct 28, 2010 3:30 pm Post subject: |
|
|
I am using SQL Refactor 1.5.1.83.......
When I hightlight the 3 SP's and press the "Parse" button it says "Command(s) completed successfully".......when I do that with "Find Unused variables and parameters".....I get the error in my original message.
Here is an example SP...........
CREATE PROCEDURE [Test].[procTest]
(
@Id uniqueidentifier
)
AS
BEGIN
SET NOCOUNT ON
DECLARE @Err int
SELECT [Id]
,[temId]
,[ActivityId]
,[AAmount]
FROM [test].[test1]
WHERE ([Id] = @Id)
IF @@Error = 0
BEGIN
IF @@RowCount = 0
BEGIN
RETURN 1
END
END
RETURN @@ERROR
END
GO |
|
| Back to top |
|
 |
Joojooflop
Joined: 01 Oct 2009 Posts: 5
|
Posted: Wed Nov 10, 2010 5:37 pm Post subject: |
|
|
I have the same issue. I still get the error if I strip down blackshirt's proc to this:
| Code: |
CREATE PROCEDURE procTest AS
IF @@Error = 0 RETURN 1
RETURN @@ERROR |
Here's another very small proc that gives the same error:
| Code: |
CREATE PROCEDURE procTest AS
DECLARE @Var1 INT
SET @Var1 = 1
SET @Var1 = 1 |
It seems to be something to do with the scan encountering the same variable a second time. For example, this is fine:
| Code: |
CREATE PROCEDURE [procTest] AS
IF @@ERROR = 0 RETURN 1
IF @@LANGID = 0 RETURN 1 |
...and this is fine:
| Code: |
CREATE PROCEDURE [procTest] AS
IF @@LANGID = 0 RETURN 1
IF @@ERROR = 0 RETURN 1 |
...but this gives the error:
| Code: |
CREATE PROCEDURE [procTest] AS
IF @@LANGID= 0 RETURN 1
IF @@LANGID= 0 RETURN 1
|
...and this gives the error:
| Code: |
CREATE PROCEDURE [procTest] AS
IF @@ERROR = 0 RETURN 1
IF @@ERROR = 0 RETURN 1
|
It's a great feature when it works. I hope it won't be too hard to fix it. |
|
| Back to top |
|
 |
mnowill
Joined: 28 Jan 2010 Posts: 4
|
Posted: Thu Apr 28, 2011 4:45 pm Post subject: Me too... |
|
|
| I am having the same issue and can reproduce the the same situations as Joojooflop |
|
| Back to top |
|
 |
Joojooflop
Joined: 01 Oct 2009 Posts: 5
|
Posted: Thu Apr 28, 2011 6:42 pm Post subject: |
|
|
| This appears to have been fixed in SQL Prompt 5. |
|
| Back to top |
|
 |
frisky
Joined: 02 Mar 2012 Posts: 2
|
Posted: Fri Mar 02, 2012 12:59 pm Post subject: Re: |
|
|
| Joojooflop wrote: |
| This appears to have been fixed in SQL Prompt 5. |
Haven't noticed any fixes. Still get the error in my original message when doing this with "Find Unused cell phone spy variables and parameters". |
|
| Back to top |
|
 |
|