Computing.Net > Forums > Database > Need help modifying SQL query

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Need help modifying SQL query

Reply to Message Icon

Name: drew22299
Date: January 21, 2009 at 08:24:29 Pacific
OS: Windows XP
CPU/Ram: 2,000 ghz
Product: N/a / N/A
Subcategory: MS SQL Server
Comment:

Hi,

I have the following query but I get an error when I run it:

The multi-part identifier "Client.ClientUID" could not be bound.

Can anyone see why?

SELECT t1.Name, t1.PeriodName

FROM (SELECT ClientRegion.Name, ClientPeriodBrief.PeriodName, Visit.Period, Visit.VisitUID

FROM Visit
INNER JOIN BatchedVisitScores ON BatchedVisitScores.VisitUID = Visit.VisitUID AND BatchedVisitScores.BranchUID = Visit.BranchUID
INNER JOIN ClientPeriodBrief ON ClientPeriodBrief.PeriodBriefUID = Visit.Period
INNER JOIN ClientRegion ON ClientRegion.ClientUID = Client.ClientUID
INNER JOIN Branch ON Branch.BranchUID = Client.ClientUID
INNER JOIN Client ON Client.ClientUID = Branch.ClientUID
WHERE Client.ClientUID = @ClientUID
) AS t1

GROUP BY t1.PeriodName, t1.Name



Sponsored Link
Ads by Google

Response Number 1
Name: michalakr
Date: January 26, 2009 at 13:28:40 Pacific
Reply:

without the schema for these tables, it's hard to give you a fixed script, but I've run a few examples here and it looks like you have one of the two possible scearions preventing you from getting this working.


1. Using a reference to an undefined table
so in your query, you are requesting SQL to join clientRegion on ClientRegion.ClientUID to Client.ClientUID but you haven't defined Client yet.


2. There is no association between the ClientRegion and previous tables.
this is a disconnect that will cause you problems.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Database Forum Home


Sponsored links

Ads by Google


Results for: Need help modifying SQL query

Need help with SQL query www.computing.net/answers/dbase/need-help-with-sql-query/629.html

Need help with SQL-query (access) www.computing.net/answers/dbase/need-help-with-sqlquery-access/209.html

Need SQL Query www.computing.net/answers/dbase/need-sql-query/366.html