Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-1172 Unused function parameters should be removed
  3. RSPEC-4111

T-SQL - Unused procedure and function parameters should be removed

    XMLWordPrintable

    Details

    • Type: Language-Specification
    • Status: Active
    • Resolution: Unresolved
    • Labels:
      None
    • Impact:
      Unknown 'null' severity
    • Likelihood:
      Unknown 'null' severity

      Description

      Noncompliant Code Example

      CREATE PROCEDURE SalesByCustomer
        @CustomerName nvarchar(50) -- Noncompliant
      AS
      SELECT c.customer_name, sum(ctr.amount) AS TotalAmount
        FROM customers c, contracts ctr
      WHERE c.customer_id = ctr.customer_id
      GROUP BY c.customer_name
      ORDER BY c.customer_name
      

      Compliant Solution

      CREATE PROCEDURE SalesByCustomer
        @CustomerName nvarchar(50)
      AS
      SELECT c.customer_name, sum(ctr.amount) AS TotalAmount
        FROM customers c, contracts ctr
      WHERE c.customer_id = ctr.customer_id
           AND c.customer_name = @CustomerName
      GROUP BY c.customer_name
      ORDER BY c.customer_name
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            massimo.paladin Massimo PALADIN
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: