Ver Mensaje Individual
  #2 (permalink)  
Antiguo 10/06/2003, 09:53
Avatar de Jorge_Mota
Jorge_Mota
 
Fecha de Ingreso: diciembre-2002
Ubicación: Chapinlandia :-D
Mensajes: 725
Antigüedad: 22 años, 2 meses
Puntos: 11
esto es por que en SQL no podes evaluar las variables de esa forma, solucion:


SET NOCOUNT ON
if @TempTable is not null
Begin
declare @cComando as nVarchar(1000)
select @cComando ='drop table '+@TempTable
exec sp_sqlexec @cComando
go
select @cComando ='Create Table '+@TempTable+' (Fechach CHAR(8), Numeroch CHAR(10),Expte NUMERIC(9),Decreto NUMERIC(9),Coddecr NUMERIC(9) ,Codestab NUMERIC(9),Importe NUMERIC(9),Partida NUMERIC(9),Jurisdicc NUMERIC(9),Mes NUMERIC(9),Anio NUMERIC(9),Estado NUMERIC(9),Institu CHAR(1),)'

exec sp_sqlexec @cComando
Go
select @cComando = 'INSERT INTO '+@TempTable+' (Fechach) VALUES('+@Fechach+')'

exec sp_sqlexec @cComando
End
GO

Solo una nota, en este caso yo elimino la tabla antes de crearla, si tienes que tener en cuenta, que antes debes averiguar si ya existe la tabla para no volverla a crear.


Saludos.
__________________
Jorge Mota
Blog
Gubiz estafa