Urgente: Problema con Insert.. Select

08/02/2005 - 18:30 por Carlos A. Díaz | Informe spam
Hola, me tiene la paciencia llena esta cuestion, tengo esta tabla (script al
final) e intento hacer a modo de ejemplo:

INSERT INTO CM
SELECT 100 AS Consulta_ID, Num_Caja, Tipo_ID, ID,NDesde, NHasta, Nodo,
INFO, Fdesde, FHasta, LDesde, LHasta,'dd' as observa,null AS Estado_ID, NULL
AS TipoEnvio, NULL AS Cantidad, NULL AS FechaDevolucion, NULL AS
RemitoDevolucion,1 AS Sale
FROM CM

pero me da el error

Server: Msg 260, Level 16, State 1, Line 1
Disallowed implicit conversion from data type smalldatetime to data type
int, table 'SAAR.dbo.cm', column 'Ndesde'. Use the CONVERT function to run
this query.
Server: Msg 260, Level 16, State 1, Line 1
Disallowed implicit conversion from data type smalldatetime to data type
int, table 'SAAR.dbo.cm', column 'Nhasta'. Use the CONVERT function to run
this query.


A que se debe ???

Gracias



CREATE TABLE [dbo].[cm] (
[ConsultaMov_ID] [int] IDENTITY (1, 1) NOT NULL ,
[Consulta_ID] [int] NULL ,
[Num_Caja] [int] NULL ,
[Tipo_ID] [tinyint] NULL ,
[ID] [int] NULL ,
[Nodo] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[INFO] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Fdesde] [smalldatetime] NULL ,
[Fhasta] [smalldatetime] NULL ,
[Ndesde] [numeric](18, 0) NULL ,
[Nhasta] [numeric](18, 0) NULL ,
[Ldesde] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Lhasta] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Observa] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Estado_ID] [tinyint] NULL ,
[TipoEnvio] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Cantidad] [smallint] NULL ,
[Sale] [bit] NOT NULL ,
[FechaDevolucion] [smalldatetime] NULL ,
[RemitoDevolucion] [int] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE INDEX [IDX1] ON [dbo].[cm]([Consulta_ID]) WITH FILLFACTOR = 90 ON
[PRIMARY]
GO

CREATE INDEX [IDX2] ON [dbo].[cm]([Tipo_ID], [ID]) WITH FILLFACTOR = 90
ON [PRIMARY]
GO

insert into cm (consulta_id,sale) values (100,0)
 

Leer las respuestas

#1 ulises
08/02/2005 - 18:51 | Informe spam
EL SELECT no tiene el mismo orden de los campos que lo que espera el
INSERT, indica en forma explícita los campos en el INSERT.

Saludos,
Ulises

On Tue, 8 Feb 2005 14:30:32 -0300, "Carlos A. Díaz" <carlosadiaz[nos
pa m]@uolsinectis.com.ar> wrote:

Hola, me tiene la paciencia llena esta cuestion, tengo esta tabla (script al
final) e intento hacer a modo de ejemplo:

INSERT INTO CM
SELECT 100 AS Consulta_ID, Num_Caja, Tipo_ID, ID,NDesde, NHasta, Nodo,
INFO, Fdesde, FHasta, LDesde, LHasta,'dd' as observa,null AS Estado_ID, NULL
AS TipoEnvio, NULL AS Cantidad, NULL AS FechaDevolucion, NULL AS
RemitoDevolucion,1 AS Sale
FROM CM

pero me da el error

Server: Msg 260, Level 16, State 1, Line 1
Disallowed implicit conversion from data type smalldatetime to data type
int, table 'SAAR.dbo.cm', column 'Ndesde'. Use the CONVERT function to run
this query.
Server: Msg 260, Level 16, State 1, Line 1
Disallowed implicit conversion from data type smalldatetime to data type
int, table 'SAAR.dbo.cm', column 'Nhasta'. Use the CONVERT function to run
this query.


A que se debe ???

Gracias



CREATE TABLE [dbo].[cm] (
[ConsultaMov_ID] [int] IDENTITY (1, 1) NOT NULL ,
[Consulta_ID] [int] NULL ,
[Num_Caja] [int] NULL ,
[Tipo_ID] [tinyint] NULL ,
[ID] [int] NULL ,
[Nodo] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[INFO] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Fdesde] [smalldatetime] NULL ,
[Fhasta] [smalldatetime] NULL ,
[Ndesde] [numeric](18, 0) NULL ,
[Nhasta] [numeric](18, 0) NULL ,
[Ldesde] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Lhasta] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Observa] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Estado_ID] [tinyint] NULL ,
[TipoEnvio] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Cantidad] [smallint] NULL ,
[Sale] [bit] NOT NULL ,
[FechaDevolucion] [smalldatetime] NULL ,
[RemitoDevolucion] [int] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE INDEX [IDX1] ON [dbo].[cm]([Consulta_ID]) WITH FILLFACTOR = 90 ON
[PRIMARY]
GO

CREATE INDEX [IDX2] ON [dbo].[cm]([Tipo_ID], [ID]) WITH FILLFACTOR = 90
ON [PRIMARY]
GO

insert into cm (consulta_id,sale) values (100,0)

Preguntas similares