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 |
|
aggiekevin
Starting Member
14 Posts |
Posted - 2007-08-20 : 18:26:36
|
| I need to use the result of a stored proc in a conditional statement.SELECT * FROM [table_name] tWHERE ( [sp_RecordExists] t.id )Unfortunately, this is not possible. Is there a similar way I can accomplish this? I know my example is simple, but I have a complicated query I am performing and need to use the result of a stored proc as a condition within my WHERE clause.Thanks! |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-08-20 : 19:49:44
|
| Get the proc result into a table and query from it.INSERT INTO #TmpResults EXEC @ProcDinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2007-08-21 : 01:08:31
|
| Try with user defined function..Can you provide more detailed explanation like.. what you are doing in the SP. What is the output SP is returning.. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-08-21 : 04:13:12
|
quote: Originally posted by aggiekevin I need to use the result of a stored proc in a conditional statement.SELECT * FROM [table_name] tWHERE ( [sp_RecordExists] t.id )Unfortunately, this is not possible. Is there a similar way I can accomplish this? I know my example is simple, but I have a complicated query I am performing and need to use the result of a stored proc as a condition within my WHERE clause.Thanks!
Create table #t(col1...........)Insert into #t EXEC sp_RecordExistsSELECT t.* FROM [table_name] t inner join #t tempon t.id=temp.idNote:Avoid prefixing sp_ for user defined proceduresMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|