Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am a beginner and need help: I have to convert my SQL query into a stored procedure. this is my original query : SELECT

I am a beginner and need help: I have to convert my SQL query into a stored procedure. this is my original query :

SELECT TM.MaintenanceID, TM.TruckNumber, TI.TruckDescription, TI.TruckCurrentMileage, LUMT.MaintenanceType, LUTT.TruckType, TM.MaintenanceStartDate, TM.MaintenanceEndDate, LUTB.TruckBodyType FROM TruckMaintenance AS TM

JOIN dbo.TruckInformation AS TI on TI.TruckNumber = TM.TruckNumber

JOIN dbo.LUTruckType AS LUTT ON LUTT.TruckTypeID = TI.TruckTypeID

JOIN dbo.LUMaintenanceType AS LUMT ON LUMT.MaintenanceTypeID = TM.MaintenanceTypeID

JOIN dbo.LUTruckBodyType AS LUTB ON LUTB.TruckBodyTypeID = TI.TruckBodyTypeID

WHERE MaintenanceStartDate BETWEEN '2018-01-01' AND '2018-12-31'

ORDER BY LUTT.TruckType ASC, TM.MaintenanceStartDate ASC.

This is my stored procedure that when i execute results in nothing

CREATE PROCEDURE [dbo].[TruckMaintenanceDates] (@MaintenanceStartDate date, @MaintenanceEndDate date)

AS

BEGIN

SELECT TM.MaintenanceID,

TM.TruckNumber,

TI.TruckDescription,

TI.TruckCurrentMileage,

LUMT.MaintenanceType,

LUTT.TruckType,

TM.MaintenanceStartDate,

TM.MaintenanceEndDate,

LUTB.TruckBodyType

FROM TruckMaintenance AS TM

JOIN dbo.TruckInformation AS TI

on TI.TruckNumber = TM.TruckNumber

JOIN dbo.LUTruckType AS LUTT

ON LUTT.TruckTypeID = TI.TruckTypeID

JOIN dbo.LUMaintenanceType AS LUMT

ON LUMT.MaintenanceTypeID = TM.MaintenanceID

JOIN dbo.LUTruckBodyType AS LUTB

ON LUTB.TruckBodyTypeID = TI.TruckBodyTypeID

WHERE

MaintenanceStartDate BETWEEN @MaintenanceStartDate AND @MaintenanceEndDate

ORDER BY LUTT.TruckType ASC,

TM.MaintenanceStartDate ASC

SET NOCOUNT ON;

END

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

Database Basics Computer EngineeringInformation Warehouse Basics From Science

Authors: Odiljon Jakbarov ,Anvarkhan Majidov

1st Edition

620675183X, 978-6206751830

More Books

Students also viewed these Databases questions

Question

5. Do you have any foreign language proficiency?

Answered: 1 week ago