Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 could not be bound?

Author  Topic 

Tomco21
Starting Member

6 Posts

Posted - 2007-05-22 : 10:45:02
Hi,

I am trying to run the following...


select PropertyID, a.*
from Property
inner join dbo.GetPropertyFacilities(Property.PropertyID)as a
on 1=1
where PropertyID = 16


The function GetPropertyFacilities basically takes the PropertyId and returns about 4 numbers which im trying to turn in to a list that looks like....

16 50
16 52
16 45
16 12

The error I'm getting is...

'Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Property.PropertyID" could not be bound.'

any help would be greatly appreciated.

Thanks

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-05-22 : 10:54:20
This is not allowed in SQL 2000. If it is SQL 2005, you need to use APPLY operator instead.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Tomco21
Starting Member

6 Posts

Posted - 2007-05-22 : 11:13:47
Thats brilliant, thank you.

For references it now works as...


select PropertyID, a.*
from Property
outer apply dbo.GetPropertyFacilities(Property.PropertyID) a


T
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-05-22 : 11:23:36
Note that OUTER APPLY works similar to LEFT JOIN in the sense it will return rows from left side table even though function does not return any row. If what you really want is INNER JOIN, you may want to go for CROSS APPLY.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -