Question Paper About Procedure
Question Paper About Procedure
Question Paper About Procedure
****
Consider the following two query results:
SELECT count(*) AS total FROM orders;
+-------+
| total |
+-------+
| 100 |
+-------+
SELECT count(*) AS cust_123_total FROM orders WHERE customer_id = '123';
+----------------+
| cust_123_total |
+----------------+
|
15
+----------------+
ANS IS :-
It give 85 record .
+----+--------------+
| 1 | John Doe
| 2 | Jane Doe
| 3 | Alice Jones |
| 4 | Bobby Louis |
| 5 | Lisa Romero |
+----+--------------+
| winner_id |
+----+----------------+-----------+
| 1 | 100 meter dash | 2
| 3 | cross-country | 2
| 4 | triathalon
| NULL
+----+----------------+-----------+
id| name
1 | John Doe
5 | Lisa Romero
executes properly.
SELECT Id, YEAR(BillingDate) AS BillingYear
FROM Invoices
WHERE BillingYear >= 2010;
ANS:
allias name can not be used here we nee d to write
SELECT Id, YEAR(BillingDate) AS BillingYear
FROM Invoices
WHERE YEAR(BillingDate) >= 2010;
Name
ReferredBy
John Doe
NULL
Jane Smith
NULL
Anne Jenkins
Eric Branford
NULL
Pat Richards
Alice Barnes
Name:
Pat Richards
SELECT Name FROM Customers WHERE Name <> 'Jane Smith' and ReferredBy
=1
or
SELECT Name FROM Customers WHERE ReferredBy = NULL OR ReferredBy <> 2
2 B
3 C
4 D
2500
1500
5500
500
Given a table TBL with a field Nmbr that has rows with
the following values:
1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1
where Nmbr is 1.
update tbl set Nmbr=
case Nmbr
when 0 then Nmbr +2
else Nmbr +3
end
A stored procedure is precompiled set of one or more SQl statements that stored
on sql server.
the main difficulties is that we don't know how many argument will be provided
during compile time.
Does storing of data in stored procedures increase the access time? Explain?
yes , the storing of data in stored procedure increase the access time.
Because Data can be precompiled and stored in Stored procedures. This reduces
the time access .
.dbo
What is the difference between a user defined function and a Stored procedure?
procedure:
1.
It is is a set of predefined (SQL) statements which are compiled once and
stored on the sql server.
2.
3.
4.
2.
3.
4.
What are external procedures ? Why and when they are used?