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.
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) __________
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.
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