0% found this document useful (0 votes)
17 views

MS SQL Question Paper - intermediate

SQl

Uploaded by

b.nagnath194
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

MS SQL Question Paper - intermediate

SQl

Uploaded by

b.nagnath194
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

INSTRUCTIONS TO BE READ BEFORE ATTEMPTING THE QUESTIONS:

 Kindly make generous use of Comments and use Transactions where required.
 There’s no restriction on the use of Google but ensure that your code does what it is supposed to.
 Please use the exact Table, Column, Function names as specified in the question paper.
 In case of any queries, please reach out to me.

1. Create a database ABCD for the bank with the same name.

2. Create a table CustomerDetails to maintain Customer Details. This table should contain the
AccountNumber which is a 10 digit long unique identifier. The FirstName and LastName of the
Customer must be captured; in addition to the BalanceAmount and PermanentAddress.

Please note that any account can have maximum 1 crore rupees, so please set the datatype
accordingly. The address may hold up to 200 characters.

3. Create another table DailyTransactions which maintains the transactions done on a daily basis.
This table will contain the following information:
TransId – 8 digit long unique identifier
FromAccount and ToAccount which are foreign keys referencing the table CustomerDetails.
Amount – to store the transaction amount
DateTimeStamp – to capture the current Date Time

4. Write a trigger Tr_CustDtl_Ins to update the BalanceAmount in the table CustomerDetails each
time there is an entry in the DailyTransaction Table.
Hint: Use Insert Trigger

5. Write a parameterized scalar function calcInterest to calculate the Interest on loan. Consider
the interest rate to be 7%.
Ask the user for Principle amount and Tenure.
Use the formula:
Interest = Principle x InterestRate x Tenure
e.g.: if Principle = 100 and Tenure = 10, then Interest = 100 x 0.07 x 10 = 70

6. Display all the daily transactions made by “ABC XYZ” with the latest transactions displayed first.
Fields to be displayed should include TransId, FromAccount, FromAccountName, ToAccount,
ToAccountName, TransAmount, TransDateTimeStamp.
Note: For FromAccountName and ToAccountName, concatenate the first and last names
corresponding to the Account Numbers

7. Display how many transactions have been made by “ABC XYZ” to “DEF MNP”. (Use the alias
TransCount)
8. Add a new column Status to the table CustomerDetails which will capture the status of the
Account. The default value of this column will be: Open.

9. Write a stored procedure sp_SuspendAccount to suspend the account of the customer who has
made 3 or more transactions exceeding 1 lakh in a day.
Hint: Update the Status column in CustomerDetails to Suspended for the said customer

10. Write a SSIS job to run the stored procedure sp_SuspendAccount once a day at 7pm.

You might also like