?
Solved

Syntax Error causing "Could not be bound error"

Posted on 2008-10-03
4
Medium Priority
?
285 Views
Last Modified: 2010-04-21
I need some help with syntax here, I keep getting a could not be bound error and I'm not sure why


 
declare @StartDate datetime
       ,@EndDate datetime
 
			set @StartDate = dateadd(d,-1, convert(datetime,convert(varchar(11),getdate(),109),109))
			set @EndDate = @StartDate+1
 
SELECT        RMI.ID 
			, RMI.Master_Incident_Number
			, RMI.Base_Response_Number
			, RMI.Time_CallEnteredQueue
			, RMI.Time_First_Unit_Enroute
			, RVA.Time_ArrivedAtScene
			, RMI.TimeFirstStaged
			, isnull(RMI.TimeFirstStaged, RVA.Time_ArrivedAtScene) AS Arrived
			, RMI.Address AS Scene_Address
			, RMI.City
			, RT.Fixed_Time_Depart_Scene
			, RT.Time_Arrive_Destination
			, RT.Address AS Destination
			, RMI.Priority_Description AS TOSCENEMODE
			, RT.Transport_Mode AS FROMSCENEMODE
			, RVA.Radio_Name AS VehicleNumber
			
 
FROM        Response_Master_Incident AS RMI
			LEFT JOIN Response_Vehicles_Assigned AS RVA 
				ON Response_Vehicles_Assigned.Master_Incident_ID = Response_Master_Incident.ID 
			LEFT JOIN Response_Transports AS RT 
				ON RT.Master_Incident_ID = Response_Master_Incident.ID
 
WHERE   	(RMI.Time_CallEnteredQueue >= @StartDate) 
		AND (RMI.Time_CallEnteredQueue < @EndDate)
		AND RMI.Master_Incident_Number is not null 
		and RMI.Priority_number in (1,2,3,4,5,6,7,12,13,14,15)
		
order by RMI.Master_Incident_Number

Open in new window

0
Comment
Question by:Aaron Goodwin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 22633470
>The multi-part identifier "TablenameD" could not be bound
your code, as shown, does not have "TablenameD" anywhere?
so, it must be some other error...


anyhow, when using table aliases, use them everywhere:

declare @StartDate datetime
       ,@EndDate datetime
 
                  set @StartDate = dateadd(d,-1, convert(datetime,convert(varchar(11),getdate(),109),109))
                  set @EndDate = @StartDate+1
 
SELECT        RMI.ID
                  , RMI.Master_Incident_Number
                  , RMI.Base_Response_Number
                  , RMI.Time_CallEnteredQueue
                  , RMI.Time_First_Unit_Enroute
                  , RVA.Time_ArrivedAtScene
                  , RMI.TimeFirstStaged
                  , isnull(RMI.TimeFirstStaged, RVA.Time_ArrivedAtScene) AS Arrived
                  , RMI.Address AS Scene_Address
                  , RMI.City
                  , RT.Fixed_Time_Depart_Scene
                  , RT.Time_Arrive_Destination
                  , RT.Address AS Destination
                  , RMI.Priority_Description AS TOSCENEMODE
                  , RT.Transport_Mode AS FROMSCENEMODE
                  , RVA.Radio_Name AS VehicleNumber
                  
 
FROM  Response_Master_Incident AS RMI
LEFT JOIN Response_Vehicles_Assigned AS RVA
  ON RVA.Master_Incident_ID = RMI.ID
LEFT JOIN Response_Transports AS RT
  ON RT.Master_Incident_ID RMI.ID
WHERE         (RMI.Time_CallEnteredQueue >= @StartDate)
            AND (RMI.Time_CallEnteredQueue < @EndDate)
            AND RMI.Master_Incident_Number is not null
            and RMI.Priority_number in (1,2,3,4,5,6,7,12,13,14,15)
            
order by RMI.Master_Incident_Number

Open in new window

0
 

Author Comment

by:Aaron Goodwin
ID: 22633595
Here are all the errors


Msg 4104, Level 16, State 1, Line 10
The multi-part identifier "Response_Vehicles_Assigned.Master_Incident_ID" could not be bound.
Msg 4104, Level 16, State 1, Line 10
The multi-part identifier "Response_Master_Incident.ID" could not be bound.
Msg 4104, Level 16, State 1, Line 10
The multi-part identifier "Response_Master_Incident.ID" could not be bound.

Is this due to me not using aliases everywhere?
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 22633739
>Is this due to me not using aliases everywhere?
yes, exactly, please try my version above.
0
 

Author Closing Comment

by:Aaron Goodwin
ID: 31502736
Yup, that was it exactly.....seems so simple, but I was looking at it for the last half hour and couldn't figure it out.  Thanks Angel!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In database programming, custom sort order seems to be necessary quite often, at least in my experience and time here at EE. Within the realm of custom sorting is the sorting of numbers and text independently (i.e., treating the numbers as number…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month8 days, 7 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question