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
 

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




Preguntas similares