Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

No encuentro las tablas declaradas con #

4 views
Skip to first unread message

A.M.F.

unread,
Jun 25, 2009, 3:08:05 PM6/25/09
to
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)=2009 and month(fecha)=6 and
day(fecha)=22 union all
select codarticul,descripcio, precioprod * -1, descuento,
cantidad,round(tot_dol/1.19,2),proveedor from satv1.dbo.devo_pro where
year(fecha)=2009 and month(fecha)=6 and day(fecha)=22 union all
select codarticul,descripci1, precioprod, cantidad,
descuento,round(tot_dol/1.19,2),proveedor from satv1.dbo.notapro where
year(fecha)=2009 and month(fecha)=6 and day(fecha)=22 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

Alejandro Mesa

unread,
Jun 25, 2009, 4:11:01 PM6/25/09
to
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)=2009 and month(fecha)=6 and
> day(fecha)=22 union all
> select codarticul,descripcio, precioprod * -1, descuento,
> cantidad,round(tot_dol/1.19,2),proveedor from satv1.dbo.devo_pro where
> year(fecha)=2009 and month(fecha)=6 and day(fecha)=22 union all
> select codarticul,descripci1, precioprod, cantidad,
> descuento,round(tot_dol/1.19,2),proveedor from satv1.dbo.notapro where
> year(fecha)=2009 and month(fecha)=6 and day(fecha)=22 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) __________

mpulla

unread,
Jun 25, 2009, 4:21:23 PM6/25/09
to
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)=2009 and month(fecha)=6 and day(fecha)=22
union all
select codarticul,descripcio, precioprod * -1, descuento,
cantidad,round(tot_dol/1.19,2),proveedor
from satv1.dbo.devo_pro

Where year(fecha)=2009 and month(fecha)=6 and day(fecha)=22
union all
Select codarticul,descripci1, precioprod, cantidad,


descuento,round(tot_dol/1.19,2),proveedor
from satv1.dbo.notapro
where year(fecha)=2009 and month(fecha)=6 and day(fecha)=22 order
by codarticul

Saludos.
Mauricio Pulla
Cuenca-Ecuador.

Penta

unread,
Jul 2, 2009, 11:20:09 PM7/2/09
to
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.

-- Cuando trataste de ejecutar el select de nuevo esta claro que YA
existe,

luego ejecuto

drop table #tabla
--Esta tabla NO existe ya que la que creaste se llama #mitabla

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

0 new messages