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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 UDF in a query

Author  Topic 

rajk
Starting Member

20 Posts

Posted - 2004-10-05 : 05:55:18
Hi,

I have a situation where I need to use a UDF in a query like in the example below:

select a.col1, b.col1, UDF (Select a.col1 where a.col4 = b.col5)
FROM table1 a , table2 b
where a.col2 = b.col2
and a.col5 = b.col5...

Here UDF is a part of the query and its input is drawn from a query which again deals with the same tables as the main query.

Hope it is clear. Please suggest a way, if there is one, to acheive this functionality.

Thanks in advance
Raj

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-10-05 : 05:57:28
well you could set your UDF to return a set of data (table) to which you can join to.
seems like the simplest way.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2004-10-05 : 08:13:50
you don't need a UDF -- just join. based on your query, you might need to read up on LEFT OUTER and INNER JOINS.

Reading your query FURTHER, it appears to make no logical sense. Please give us two sample tables with a little sample data and what you hope to return from these two tables. Please post 2 CREATE TABLE statements and some INSERT statements that populate these tables with data so we can help you.

- Jeff
Go to Top of Page
   

- Advertisement -