No encuentro las tablas declaradas con #

25/06/2009 - 21:08 por A.M.F. | Informe spam
Hola

quiero correr la siguietne sentencia:

select codarticul,descripcio, precioprod, cantidad,
descuento,round(tot_dol/1.19,2) as total_sigv,proveedor into #mitabla from
satv1.dbo.archtra3 where year(fecha) 09 and month(fecha)=6 and
day(fecha)" union all
select codarticul,descripcio, precioprod * -1, descuento,
cantidad,round(tot_dol/1.19,2),proveedor from satv1.dbo.devo_pro where
year(fecha) 09 and month(fecha)=6 and day(fecha)" union all
select codarticul,descripci1, precioprod, cantidad,
descuento,round(tot_dol/1.19,2),proveedor from satv1.dbo.notapro where
year(fecha) 09 and month(fecha)=6 and day(fecha)" order by codarticul

me sale el siguiente error:

Msg 2714, Level 16, State 6, Line 1
There is already an object named '#mitabla' in the database.

luego ejecuto

drop table #tabla

y me sale el error

Msg 3701, Level 11, State 5, Line 1
Cannot drop the table '#tabla', because it does not exist or you do not have
permission.

Como puedo solucionar todo esto?

Luis


__________ Información de ESET NOD32 Antivirus, versión de la base de firmas de virus 4187 (20090625) __________

ESET NOD32 Antivirus ha comprobado este mensaje.

http://www.eset.com

Preguntas similare

Leer las respuestas

#1 Alejandro Mesa
25/06/2009 - 22:11 | Informe spam
A.M.F.,

Creo que debes cojer un break.

Estas intentando insertar en "#mitabla" pero estas eliminando "#tabla".

Lo que puedes hacer es poner este codigo al principio del script.

if object_id('tempdb..#mitabla') is not null
drop table #mitabla;

...


AMB



"A.M.F." wrote:

Hola

quiero correr la siguietne sentencia:

select codarticul,descripcio, precioprod, cantidad,
descuento,round(tot_dol/1.19,2) as total_sigv,proveedor into #mitabla from
satv1.dbo.archtra3 where year(fecha) 09 and month(fecha)=6 and
day(fecha)" union all
select codarticul,descripcio, precioprod * -1, descuento,
cantidad,round(tot_dol/1.19,2),proveedor from satv1.dbo.devo_pro where
year(fecha) 09 and month(fecha)=6 and day(fecha)" union all
select codarticul,descripci1, precioprod, cantidad,
descuento,round(tot_dol/1.19,2),proveedor from satv1.dbo.notapro where
year(fecha) 09 and month(fecha)=6 and day(fecha)" order by codarticul

me sale el siguiente error:

Msg 2714, Level 16, State 6, Line 1
There is already an object named '#mitabla' in the database.

luego ejecuto

drop table #tabla

y me sale el error

Msg 3701, Level 11, State 5, Line 1
Cannot drop the table '#tabla', because it does not exist or you do not have
permission.

Como puedo solucionar todo esto?

Luis


__________ Información de ESET NOD32 Antivirus, versión de la base de firmas de virus 4187 (20090625) __________

ESET NOD32 Antivirus ha comprobado este mensaje.

http://www.eset.com




Respuesta Responder a este mensaje
#2 mpulla
25/06/2009 - 22:21 | Informe spam
La sentencia:

Select campo1, campo2
Into mitabla
From satv1.dbo.archtra3
Where ?

Te crea una tabla

Crea primero la tabla temporal y luego cambia la sentencia a:

Insert Into #tabla
select codarticul,descripcio, precioprod, cantidad,
descuento,round(tot_dol/1.19,2) as total_sigv,proveedor
from satv1.dbo.archtra3
where year(fecha) 09 and month(fecha)=6 and day(fecha)"
union all
select codarticul,descripcio, precioprod * -1, descuento,
cantidad,round(tot_dol/1.19,2),proveedor
from satv1.dbo.devo_pro
Where year(fecha) 09 and month(fecha)=6 and day(fecha)"
union all
Select codarticul,descripci1, precioprod, cantidad,
descuento,round(tot_dol/1.19,2),proveedor
from satv1.dbo.notapro
where year(fecha) 09 and month(fecha)=6 and day(fecha)" order
by codarticul

Saludos.
Mauricio Pulla
Cuenca-Ecuador.
Respuesta Responder a este mensaje
#3 Penta
03/07/2009 - 05:20 | Informe spam
Estimado.
La tabla temporal se crea de manera correcta LA PRIMERA VEZ

Msg 2714, Level 16, State 6, Line 1
There is already an object named '#mitabla' in the database.
existe,

luego ejecuto

drop table #tabla



Msg 3701, Level 11, State 5, Line 1
Cannot drop the table '#tabla', because it does not exist or you do
not have
permission.

Atte.
PENTA
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida