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.
| Author |
Topic |
|
sql777
Constraint Violating Yak Guru
314 Posts |
Posted - 2007-05-08 : 10:11:08
|
| Hello,I have a query that I need to put in either a function or stored procedure. This query will return a list of ID's. I need to call this function/procedure as a subquery:select *from tableA twhere t.id in ( *** MY FUNCTION *** )What is the standard practise for this type of problem? |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-05-08 : 10:19:45
|
| table valued functionselect *from tableA twhere t.id in (select id from dbo.myfunc)Depends on what you want to do with it but consider putting the result in a temp table then using that.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
herothecat
Starting Member
19 Posts |
Posted - 2007-05-08 : 22:02:50
|
| I would actually suggest to try it with the function, then with a temp table, then a CTE, and finally with a table variable.My experience has proven that depending on the amount of data and complexity of the "function" (joins, aggregates etc..) one of the four will be the best. BUT it's not always the same.Why push the envelope when you can just open it? |
 |
|
|
|
|
|