| Author |
Topic |
|
akashenk
Posting Yak Master
111 Posts |
Posted - 2007-02-01 : 04:50:28
|
| Can anyone help me get the UNION of the the result of two EXEC statements within my SP. So, for example, in my Store Procedure, I call another stored procedure twice using EXEC to get two groups of data and I want to return the union of these.Thanks |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-02-01 : 04:58:06
|
| Create a temp table and put the results of both SPs into it then do a distinct on the result.==========================================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. |
 |
|
|
akashenk
Posting Yak Master
111 Posts |
Posted - 2007-02-01 : 05:05:04
|
| I think I know how to create a temp table, but how do I place the results of the SPs into it? |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-02-01 : 05:14:39
|
| insert #a exec mysp==========================================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. |
 |
|
|
akashenk
Posting Yak Master
111 Posts |
Posted - 2007-02-01 : 05:18:47
|
| Can I do the same with a table variable instead of a temporary table? |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-02-01 : 05:34:56
|
no. You can't KH |
 |
|
|
akashenk
Posting Yak Master
111 Posts |
Posted - 2007-02-01 : 05:47:51
|
| Thanks for your help. |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-02-01 : 06:09:39
|
| Actually with v2005 you can.It would take you a couple of minutes to try it for yourself.==========================================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. |
 |
|
|
akashenk
Posting Yak Master
111 Posts |
Posted - 2007-02-01 : 06:16:59
|
| got it... thanks. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-02-01 : 07:08:24
|
quote: Originally posted by nr Actually with v2005 you can.It would take you a couple of minutes to try it for yourself.==========================================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.
Oh . . did not know that  KH |
 |
|
|
|