Hey Experts!
Trying to learn a bit about SQL for a project I'm working on.
I have a stored procedure (sp_TestEmployeeTimeRecord
WithRate) which allows me to query a few tables and returns a calculated result called 'RecordBillTotal'. This Query is perfect, however I would like to create a second stored procedure that will then take that 'RecordBillTotal' and place it into a column called TimeRecordBillTotal in a tabled called TimeRecord.
Over all Goal being is that our accountant could run the Stored Procedure based upon a set of values which then update a column in the origianl record.
I have pasted my current Stored Procedure below
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER Procedure [dbo].[sp_TestEmployeeTime
RecordWith
Rate]
@TimeRecName nchar(50), @TimeRecProjectNumber nchar (6)
AS
SELECT TimeRecord.TimeRecEmployee
Name, TimeRecord.TimeRecHours, TimeRecord.TimeRecProjectN
umber, ProjectInformation.Project
BillRateZo
neName,
EmployeeInformation.Employ
eeBillRate
Zone, TestBillRates.Rate, (TestBillRates.Rate * TimeRecord.TimeRecHours)AS
RecordBillTotal
FROM TestBillRates INNER JOIN
ProjectInformation ON TestBillRates.Zone = ProjectInformation.Project
BillRateZo
neName INNER JOIN
EmployeeInformation ON TestBillRates.EmployeeRate
= EmployeeInformation.Employ
eeBillRate
Zone INNER JOIN
TimeRecord ON EmployeeInformation.Employ
eeName = TimeRecord.TimeRecEmployee
Name AND
ProjectInformation.Project
Number = TimeRecord.TimeRecProjectN
umber
WHERE TimeRecord.TimeRecEmployee
Name = @TimeRecName AND TimeRecord.TimeRecProjectN
umber = @TimeRecProjectNumber
Start Free Trial