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 |
sqldba20
Posting Yak Master
183 Posts |
Posted - 2008-11-25 : 09:56:54
|
Folks:I have a query which combines 2 temp tables. I ran the query with # tables and the query finishes (returns results) in less than 25 secs. The problem is I want to use this query as tvf (function) and I cannot use # tables in functions so I use the variable tables and then it takes 2 mins to complete the process. What are my options?Thanks! |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-11-25 : 10:11:43
|
Hard to guess without seeing what your code is doing. E 12°55'05.63"N 56°04'39.26" |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-25 : 12:17:50
|
quote: Originally posted by sqldba20 Folks:I have a query which combines 2 temp tables. I ran the query with # tables and the query finishes (returns results) in less than 25 secs. The problem is I want to use this query as tvf (function) and I cannot use # tables in functions so I use the variable tables and then it takes 2 mins to complete the process. What are my options?Thanks!
Try if you can rewrite code as inline table function. type 2 in below linkhttp://www.sqlteam.com/article/user-defined-functions |
 |
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2008-11-25 : 13:01:42
|
Instead of using temp tables in your function, use Common Table Expressions.If it is not practically useful, then it is practically useless. |
 |
|
|
|
|