copy records from a table with foreign keys

0

by inserting the ReprteRegresado table and copying the data from the report table:

INSERT INTO [dbo].[ReporteEgresado]
           ([Observacion_ReporteEgresado]
           ,[Sancion_ReporteEgresado]
           ,[Fecha_ReporteEgresado]
           ,[AlumnoEgresado_Curp_AlumnoEgresado]
           ,[Grado_ReporteEgresado]
           ,[Grupo_ReporteEgresado]) select * from Reporte

I get this error:

  

"The selection list for the INSERT statement contains more   Elements that the insert list. The number of SELECT values must   match the number of INSERT columns. "

    
asked by Irving Frias 13.12.2017 в 23:51
source

1 answer

2

With doing a select * FROM Reporte , you are bringing 7 columns and you only put the INSERT in 6, the Id_reporte is the one that is over, you will have to

INSERT INTO [dbo].[ReporteEgresado]
           ([Observacion_ReporteEgresado]
           ,[Sancion_ReporteEgresado]
           ,[Fecha_ReporteEgresado]
           ,[AlumnoEgresado_Curp_AlumnoEgresado]
           ,[Grado_ReporteEgresado]
           ,[Grupo_ReporteEgresado]) 
 select 
 Observacion_Reporte, Sancion_Reporte {...} from Reporte

To remove the id_reporte of the query

    
answered by 13.12.2017 / 23:56
source