I am using this query:
INSERT INTO Registro_EQ (Codigo, Fechtran, Fechaini, Fechaexp, IDCONF, Descripcion, Marca, Modelo, Serie, ConLista, Porcentaje_cl, SinLista, Porcentaje_sl, Movible,
Porcentaje_mv, Edificio, Porcentaje_ed, Automatico, Exceso, Porcentaje_ex, Asignacion, Estatus, IDUsuario)
SELECT DATEADD(year, 1, Fechaini) as Fecha, DATEADD(year, 1, Fechaexp) as Fecha2,
[Codigo] , [Fechtran], [IDCONF], [Descripcion], [Marca], [Modelo], [Serie], [ConLista], [Porcentaje_cl], [SinLista], [Porcentaje_sl], [Movible],
[Porcentaje_mv], [Edificio], [Porcentaje_ed], [Automatico], [Exceso], [Porcentaje_ex], [Asignacion], [Estatus], [IDUsuario]
FROM [Pru].[dbo].[Registro_EQ]
WHERE Fechaini >= '2016-01-01' AND Fechaini < '2017-01-01'
When I run send me the following message:
Conversion failed when converting date and/or time from character string.
I know that is by datetime, but I couldn't find the answer.
The order on Insert Into is Codigo, Fechtran, Fechaini, Fechaexp, IDCONF and in the Select the order is different, Fecha, Fecha2, Codigo, Fechtran, IDCONF.
So you're most likely inserting data to wrong columns.