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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Using Temp File

Author  Topic 

snufse
Constraint Violating Yak Guru

469 Posts

Posted - 2014-10-02 : 15:26:11
Have a sp that does not return records (timeout) when I use temp table, if I run without temp table (insert into...) records are returned fine, happens on 2005 and 2008. I am am using linked server and rpc = True. This used to work all along but cannot figure out what has changed. Thank you.


declare @JobNumber int
declare @DateFrom datetime
declare @DateTo datetime

set @JobNumber = 6107416
set @DateFrom = '2014-9-1 00:00:00'
set @DateTo = '2014-9-15 23:59:59'

SET NOCOUNT ON

If Object_ID('tempdb..#Table') Is Not Null Drop Table #Table

CREATE TABLE #Table
( eq_cost_code nvarchar(15) unique,
eq_item_name char(15),
eq_sum_hrs decimal(10,2)
)
begin
insert into #Table (eq_cost_code,
eq_item_name,
eq_sum_hrs
)
exec [SQL2].Labor.dbo.sp_EquipmentInquiry @JobNumber, @DateFrom, @DateTo
end

select *
from #Table

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-10-02 : 15:44:00
Do you mean that in SSMS you can comment out the insert into command, the temp table is populated, but if you let that run, it times out?

How many rows are we talking about?
Go to Top of Page
   

- Advertisement -