Sunday, February 19, 2012

DTS with temporary tables

Hello,

I tried to make a DTS to transform data in a text file, I used a Store Procedure that use a temp table (#Resultados) but the DTS give me an error.

I read that in this case I can′t use local temp tables but I can use global temp tables, then I changed in my Store, #Resultados by ##Resultados, bu the result was the same.

My Store is likely to his. Please help me.


INSERT ##Resultados (Planta, Etapa,GrupoEquipo,Equipo,Concepto,Fecha,Guardia,

Valor,idConcepto)
EXEC CalculosDiarios @.Area,@.Reporte,@.FechaIni,@.FechaFin,0

SELECT LEFT(RP.Grupo,3) + LEFT(RP.Equipo,12) + LEFT(RP.SubGrupo,2)
+ LEFT(D.Fecha,8) + D.Valor as Dato
FROM
ReportesPlantilla RP
LEFT JOIN
##Resultados D
ON
RP.Planta = D.Planta
AND RP.Etapa = D.Etapa
AND RP.GrupoEquipo = D.GrupoEquipo
AND RP.Equipo = D.Equipo
AND RP.Concepto = D.Concepto
AND D.Fecha BETWEEN @.FechaIni AND @.FechaFin

What is the error message that you are getting?|||

Hi,

The error is:

Error Source : Microsoft OLE DB Provider for SQL Server

Error Description : Invalid Object Name '##Resultados'

When I run the Store in Query Analizer everything run OK.

|||

That is what I thought was going on. Sometimes when working with the ##tempTables in DTS you will need to work around it. What I often do is something like this:

Create the ##temp table in query analyzer Create the DTS steps Then drop the ##temp table in query analyzer|||Great, It worked, thanks a lot....

No comments:

Post a Comment