Question
Create a single SQL script that will do the follow. Comment each step. Problem 1: Using the Script for provided for this weeks video do
Create a single SQL script that will do the follow. Comment each step.
Problem 1:
Using the Script for provided for this weeks video do the following.
The ABC Company now wants you to create stored procedures to calculate federal, state and local taxes for an employee based on their gross income and what state they live in.
Federal taxes will be calculated as follows:
Gross weekly pay < 961.54 the tax rate will be .07
Gross weekly pay between 961.54 and 1923.08 the tax rate will be .08
Gross weekly pay > 1923.08 the tax rate will be .09
State and Local taxes will be calculated using the state and local rates in TTaxRates for each employee.
- Create the stored procedure uspCalculateTaxes that will accept employee ID and weekly salary. Outputs will be federal, state and local tax. Create a cursor within this stored procedure GetTaxRates which will pull state and local rate from TTaxRates for the employee. For federal tax use an IF statement to set the rate based on the weekly gross and then calculate the tax owed. Call this stored proc from within uspGetGrossPay.
- Create a Table called TPayrolls. This table should hold employee ID, gross pay (weekly), federal tax, state tax, local tax and the current date (Use GetDate()) for the value on this). Use the IDENTITY property for the PK key column in TPayrolls.
- Create the stored procedure uspAddPayroll. Once you call uspGetGrossPay which calls uspCalculateTaxes you will then call uspAddPayroll within uspGetGrossPay and insert the calculated data into TPayrolls. IE Your calls to uspCalculateTaxes and uspAddPayroll will go in uspGetGrossPay between the last two END statements. This is a one call does it all script. You call uspGetGrossPay and it will calculate all taxes and write the record into the table.
- Create a test call to the stored procedure after you create it to make sure it works correctly for each type of employee. This means you will need to call 3 salary and 3 hourly employees. You will need 1 each for the federal tax rates of .07, .08 and .09 as listed above for each. Set your data up accordingly. Once you have tested your code please comment your test code out prior to submitting.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started