Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

  1. 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.
  2. 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.
  3. 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.
  4. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

More Books

Students also viewed these Databases questions

Question

2. Define communication.

Answered: 1 week ago