31 lines
671 B
Plaintext
31 lines
671 B
Plaintext
![]() |
include::../description.adoc[]
|
||
|
|
||
|
== 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
|
||
|
----
|
||
|
|
||
|
include::../see.adoc[]
|