'How do you create a stored procedure with two parameters being a specific Id# and a datetime
I am trying to create a stored procedure that retrieves a list of of vehicleID's and their corresponding most recent FixDate, if they have one. The problem I am having is finishing the last line, I was instructed to use something along the lines of 'vehList[x]'. When i try to use it it does not work and generate the list. Do I need to add another parameter and if so, how would I apply it.
I am getting an error message since I know it can't create the query but I don't know what to add to after 'where v.Code = ____'
The column I want to pull from is called 'VehicleID' when I try yo use it I get an error that says Ambiguous column name.
I am getting an error message.
Msg 8114, Level 16, State 5, Line 1 Error converting data type nvarcahr to bigint.
CREATE PROCEDURE LastFixTaken
@FixDate DateTime,
As SELECT Max(FixTaken) As LastFixTaken
From VehilceHistory vh
JOIN Vehicle v On v.VehicleID = vh.CehicleID
where v.Code = vehList[x]
I am not sure what to put after the v.Code as I am trying to retrieve a list of all Vehicles with a recent fix date if I insert a specific vehicle ID in strings the procedure works. I was told to use vehList[x] but that isn't working.
Any help would be greatly appreciated and if you have any further questions I'll do my best to help, thanks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
