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

MS SQL Question Paper - Basic

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)
10 views

MS SQL Question Paper - Basic

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. Write a script to create a new database named StoreInvDetails. Use this database to write the
rest of your test in.

2. Write a script to create a table MobileStoreInventory which maintains mobile phone inventory
details. This table should contain the columns ModelNo, Company, CostPerUnit, and Quantity.
Please note that the ModelNo is alphanumeric and is the primary key. Please pick appropriate
datatype for the other three columns judiciously.

3. Write a script to add any three records into the table MobileStoreInventory.

4. Write a script to change the Company of ModelNo ‘FETE0987’ to ‘ETE’.

5. Write a script to change the Quantity to 56 and CostPerUnit to 2345 for the ModelNo
‘AZBYCX12345’ and Quantity is 60.

6. Write a script to copy all the records for the Company “CCC” from the table
MobileStoreInventory into a new table InvArchive.

7. Write a script to copy all the records Company “DDD” from the table MobileStoreInventory into
the table InvArchive.

8. Write a script to remove all the records for Company “EXS” from the table
MobileStoreInventory.

9. a) List all the Companies along with the count of records against them in the table
MobileStoreInventory

b) Amend the above query such that it looks specifically for Company “AAA”

10. Write a script to create a table DistributionList which captures the DistributorID, ModelNo,
QuantityDispatched where DistributorID is NOT the primary key of the table and ModelNo
references the table MobileStoreInventory. Please pick appropriate datatype for the columns
judiciously.

MS SQL (Basic) Test Paper Roshan Varghese


11. Write a script to amend the datatype of the column CostPerUnit of table MobileStoreInventory
to NUMERIC(8,2)

12. Write a script to display the DistributorID, CostPerUnit, QuantityAvailable (use alias) and
QuantityDispatched for all the Companies starting with “M”

13. Write a script to display the ModelNo that has been dispatched the most.
(Hint: Use DistributionList)

14. Write a select query to display the current date in DD/MM/YYYY hh:mm:ss format

15. Write a script to copy all the records from the table MobileStoreInventory where the Company
name starts with “B” into a temp table #MobInvB. Consider only the columns Company and
ModelNo.

16. Write a script to copy all the records from the table MobileStoreInventory where the Company
name ends with “T” into a temp table #MobInvT. Consider only the columns Company and
ModelNo.

17. Write a script to display only the common records of #MobInvB and #MobInvT

18. Write a script to display all the records of #MobInvB but not those which are present in
#MobInvT

19. Remove all the records of #MobInvB and #MobInvT without affecting their table structure.

MS SQL (Basic) Test Paper Roshan Varghese

You might also like