Advertisement

05.02.2008 at 06:45AM PDT, ID: 23371513
[x]
Attachment Details

Question on temp tables in stored procedures

Asked by countrymeister in SQL Server 2005, MS SQL Server

Tags: T-sql, T-sql

I have a stored procedure P1 which creates a temp table #tmpT1, this stored procedure P1 calls another stored proc P2, the insert in the temp table occurs in P2, when I do a select count on the table in procedure P2,  I always get  a value of zero.

But when I do a select in P1 just after the exec of P2, I do get the totalsStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
P1 logic
---------------------------------------
CREATE TABLE #tmpExp
(
    CurrencyID char(3)
    Desc varchar(20) 
 
) 
 
exec P2
 
print select count(*) from #tmpExp
----------------------------------------------------
P2 logic
 
Insert into #tmpExp
select * from Table Exp
 
print select count(*) from #tmpExp
[+][-]05.02.2008 at 06:49AM PDT, ID: 21486597

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.02.2008 at 07:15AM PDT, ID: 21486831

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.02.2008 at 08:01AM PDT, ID: 21487196

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.03.2008 at 12:13PM PDT, ID: 21493426

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.03.2008 at 12:30PM PDT, ID: 21493475

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.04.2008 at 03:18AM PDT, ID: 21495230

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.04.2008 at 07:17PM PDT, ID: 21497783

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.04.2008 at 08:24PM PDT, ID: 21498010

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: SQL Server 2005, MS SQL Server
Tags: T-sql, T-sql
Sign Up Now!
Solution Provided By: mikosha
Participating Experts: 3
Solution Grade: A
 
 
[+][-]05.05.2008 at 04:13AM PDT, ID: 21499104

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628