CREATE PROCEDURE get_ticket_companies
@TicketId varchar(30)
AS
SELECT tbl_company.EnterpriseID, tbl_company.Company, tbl_index_ticket_companies.LocationID,
tbl_index_ticket_companies.DateAdded, tbl_index_ticket_companies.AgentAdded
FROM tbl_index_ticket_companies JOIN tbl_locations
ON tbl_index_ticket_companies.LocationID = tbl_locations.LocationID
JOIN tbl_company
ON tbl_locations.EnterpriseID = tbl_company.EnterpriseID
WHERE tbl_index_ticket_companies.TicketID = @TicketId
ORDER BY tbl_index_ticket_companies.DateAdded ASC