Author |
Topic |
mayoorsubbu
Yak Posting Veteran
95 Posts |
Posted - 2008-10-03 : 23:48:15
|
Hi,Could someone tell me how can I join a table with the output od a Sp : SQL Server 2000Thanx |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-10-04 : 02:28:57
|
http://sqlblogcasts.com/blogs/madhivanan/archive/2007/11/26/select-columns-from-exec-procedure-name-is-this-possible.aspxMadhivananFailing to plan is Planning to fail |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-04 : 02:56:08
|
In addition to method suggested in link, you can use a temporary table and dump resultset of SP into itINSERT #TempEXEC Spname params.... then use it to join to yourtableSELECT *FROM YourTable tJOIN #Temp tmpON tmp.fields=t.fields.... you should make sure that the structure of temporary table matches the resultset of SP. |
 |
|
mayoorsubbu
Yak Posting Veteran
95 Posts |
Posted - 2008-10-06 : 06:54:02
|
Hi Visakh16,I appreciate your reply. However there is one problem and that is the Sp expects one parameter (itemcode) and also returns a result set that has the itemcode among other information. The itemcode is also there in the join condition.Table1itemcode item123 xyz345 abcI want to join table1 with the result of the Sp where itemcode of table1 matches the sp output.Thanx |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-06 : 07:06:33
|
ok so for every records of table you want sp to return results based on one of column value as parameter? is that what you want? in such case its best to create a udf rather than sp. udfs have more usability compared to sps as they can be used flexibly on both select statements and joins. |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-10-06 : 08:32:02
|
What you need seems to be SQL Server 2005 and CROSS APPLY. E 12°55'05.63"N 56°04'39.26" |
 |
|
mayoorsubbu
Yak Posting Veteran
95 Posts |
Posted - 2008-10-06 : 09:11:59
|
Visakh16,You have got the point. I haven't created a udf in Sql Server. Looking for some assistance.Thanx |
 |
|
mayoorsubbu
Yak Posting Veteran
95 Posts |
Posted - 2008-10-06 : 09:20:20
|
Visakh16,You have got the point. I have not created an Udf in Sql Server though have done so in VFP. Looking for assistance.Thanx |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-06 : 09:32:52
|
quote: Originally posted by mayoorsubbu Visakh16,You have got the point. I have not created an Udf in Sql Server though have done so in VFP. Looking for assistance.Thanx
http://www.sqlteam.com/article/user-defined-functions |
 |
|
mayoorsubbu
Yak Posting Veteran
95 Posts |
Posted - 2008-10-07 : 09:39:25
|
Thanx Visakh16 |
 |
|
|