Home All Groups Group Topic Archive Search About

Returning a table into a SP from an SP

Author
12 May 2005 1:00 PM
Dave
I have a SP called SP_GetTable.  In a seperate SP how do perform the
following?

CREATE procedure SP_GetValuefromSP
as

DECLARE @MyTable (@Field1 Integer, @Field2 Integer)

Insert into @MyTable [Results from SP_GetTable]

return 0
go



Thanks,

Dave.

Author
12 May 2005 1:08 PM
Dave
I think I've figured it out.  You have to create a temporary table as
you cannot insert the results of a SP into a memory table.  Are there
any "dangers" to using Temporary Tables?  These SP will not be run
often (maybe once every week)

Thanks again,

Dave.

On Thu, 12 May 2005 09:00:33 -0400, Dave <D***@here.ca> wrote:

Show quote
>I have a SP called SP_GetTable.  In a seperate SP how do perform the
>following?
>
>CREATE procedure SP_GetValuefromSP
>as
>
>DECLARE @MyTable (@Field1 Integer, @Field2 Integer)
>
>Insert into @MyTable [Results from SP_GetTable]
>
>return 0
>go
>
>
>
>Thanks,
>
>Dave.
Author
12 May 2005 9:39 PM
Hugo Kornelis
On Thu, 12 May 2005 09:08:06 -0400, Dave wrote:

>I think I've figured it out.  You have to create a temporary table as
>you cannot insert the results of a SP into a memory table.  Are there
>any "dangers" to using Temporary Tables?  These SP will not be run
>often (maybe once every week)

Hi Dave,

A table variable is stored in tempdb. If it's small and short-lived, it
will never make it from cache to the disk - but the same can be said
about a temp table! Because temp table operations are not logged, there
is some reduction in disk activity for the log file. But calling a table
variable "memory based" is misleading.

"Should I use a #temp table or a @table variable?" www.aspfaq.com/2475

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Author
13 May 2005 6:33 AM
Tibor Karaszi
Hugo,

Sorry for nit-picking, just one small detail:

>  Because temp table operations are not logged,

Operations against temp tables are logged. Same goes for table variables, with a little bit less
logging compared to temp tables. Only UNDO operations are logged for both, not REDO operations.

Show quote
"Hugo Kornelis" <hugo@pe_NO_rFact.in_SPAM_fo> wrote in message
news:s2j7815r2crptq8clfac0d36sj2esf4fd6@4ax.com...
> On Thu, 12 May 2005 09:08:06 -0400, Dave wrote:
>
>>I think I've figured it out.  You have to create a temporary table as
>>you cannot insert the results of a SP into a memory table.  Are there
>>any "dangers" to using Temporary Tables?  These SP will not be run
>>often (maybe once every week)
>
> Hi Dave,
>
> A table variable is stored in tempdb. If it's small and short-lived, it
> will never make it from cache to the disk - but the same can be said
> about a temp table! Because temp table operations are not logged, there
> is some reduction in disk activity for the log file. But calling a table
> variable "memory based" is misleading.
>
> "Should I use a #temp table or a @table variable?" www.aspfaq.com/2475
>
> Best, Hugo
> --
>
> (Remove _NO_ and _SPAM_ to get my e-mail address)
Author
13 May 2005 11:39 PM
Hugo Kornelis
On Fri, 13 May 2005 08:33:11 +0200, Tibor Karaszi wrote:

>Hugo,
>
>Sorry for nit-picking, just one small detail:
>
>>  Because temp table operations are not logged,
>
>Operations against temp tables are logged. Same goes for table variables, with a little bit less
>logging compared to temp tables. Only UNDO operations are logged for both, not REDO operations.

Hi Tibor,

Don't apologize for catching my goofs. I don't know how I managed to
write and post that. I meant to write "Because table variable operations
are not logged" - and obviously, even that would not heve been correct
(but at least less incorrect than the nonsense I did post <blush>

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Author
15 May 2005 4:50 PM
Tibor Karaszi
Hi Hugo,

> I meant to write "Because table variable operations
> are not logged"

And that is how I first read it, and started typing based on that; before re-reading your post. :-)

Show quote
"Hugo Kornelis" <hugo@pe_NO_rFact.in_SPAM_fo> wrote in message
news:jjea8150j1gaifesscmvrhpuehgcqmfdt0@4ax.com...
> On Fri, 13 May 2005 08:33:11 +0200, Tibor Karaszi wrote:
>
>>Hugo,
>>
>>Sorry for nit-picking, just one small detail:
>>
>>>  Because temp table operations are not logged,
>>
>>Operations against temp tables are logged. Same goes for table variables, with a little bit less
>>logging compared to temp tables. Only UNDO operations are logged for both, not REDO operations.
>
> Hi Tibor,
>
> Don't apologize for catching my goofs. I don't know how I managed to
> write and post that. I meant to write "Because table variable operations
> are not logged" - and obviously, even that would not heve been correct
> (but at least less incorrect than the nonsense I did post <blush>
>
> Best, Hugo
> --
>
> (Remove _NO_ and _SPAM_ to get my e-mail address)

AddThis Social Bookmark Button