obtener todas las entradas en un objeto

Hello I have a beginner question

I have received following statment

SELECT * INTO #tmp_GridResults_1
FROM (
SELECT N'1333010121' AS [PcbID], N'2012-03-29 10:35:21.067' AS [TimeDone], N'5011' AS [McID], N'1' AS [CountPCB], N'0' AS [DeviceID], N'' AS [Program], N'1' AS [CycleTime], N'0' AS [NumComp], N'1' AS [NumBlocks], N'0' AS [NumErrors], N'' AS [OrderNo], NULL AS [Operation], N'1' AS [Lane], N'0' AS [SerializedID] UNION ALL
SELECT N'1333010148' AS [PcbID], N'2012-03-29 10:35:48.943' AS [TimeDone], N'5012' AS [McID], N'1' AS [CountPCB], N'0' AS [DeviceID], N'' AS [Program], N'1690' AS [CycleTime], N'179' AS [NumComp], N'1' AS [NumBlocks], N'0' AS [NumErrors], N'' AS [OrderNo], NULL AS [Operation], N'1' AS [Lane], N'0' AS [SerializedID] UNION ALL
SELECT N'1333010156' AS [PcbID], N'2012-03-29 10:35:56.177' AS [TimeDone], N'201' AS [McID], N'1' AS [CountPCB], N'0' AS [DeviceID], N'' AS [Program], N'263' AS [CycleTime], N'16' AS [NumComp], N'1' AS [NumBlocks], N'0' AS [NumErrors], N'' AS [OrderNo], NULL AS [Operation], N'1' AS [Lane], N'0' AS [SerializedID] UNION ALL
SELECT N'1333017866' AS [PcbID], N'2012-03-29 12:44:26.903' AS [TimeDone], N'5011' AS [McID], N'148' AS [CountPCB], N'0' AS [DeviceID], N'' AS [Program], N'1' AS [CycleTime], N'0' AS [NumComp], N'1' AS [NumBlocks], N'0' AS [NumErrors], N'' AS [OrderNo], NULL AS [Operation], N'1' AS [Lane], N'0' AS [SerializedID] ) t;
SELECT [PcbID], [TimeDone], [McID], [CountPCB], [DeviceID], [Program], [CycleTime], [NumComp], [NumBlocks], [NumErrors], [OrderNo], [Operation], [Lane], [SerializedID]
FROM #tmp_GridResults_1

How I can take now everything that I have in #tmp_GridResults_1 and to insert it to some table ?

preguntado el 05 de mayo de 13 a las 12:05

1 Respuestas

I think you don't need to sotre the records in a variable because you can directly insert the records on the other table.

INSERT INTO tableName([PcbID], [TimeDone], [McID], [CountPCB], [DeviceID], [Program], [CycleTime], [NumComp], [NumBlocks], [NumErrors], [OrderNo], [Operation], [Lane], [SerializedID])
SELECT N'1333010121' AS [PcbID], N'2012-03-29 10:35:21.067' AS [TimeDone], N'5011' AS [McID], N'1' AS [CountPCB], N'0' AS [DeviceID], N'' AS [Program], N'1' AS [CycleTime], N'0' AS [NumComp], N'1' AS [NumBlocks], N'0' AS [NumErrors], N'' AS [OrderNo], NULL AS [Operation], N'1' AS [Lane], N'0' AS [SerializedID] UNION ALL
SELECT N'1333010148' AS [PcbID], N'2012-03-29 10:35:48.943' AS [TimeDone], N'5012' AS [McID], N'1' AS [CountPCB], N'0' AS [DeviceID], N'' AS [Program], N'1690' AS [CycleTime], N'179' AS [NumComp], N'1' AS [NumBlocks], N'0' AS [NumErrors], N'' AS [OrderNo], NULL AS [Operation], N'1' AS [Lane], N'0' AS [SerializedID] UNION ALL
SELECT N'1333010156' AS [PcbID], N'2012-03-29 10:35:56.177' AS [TimeDone], N'201' AS [McID], N'1' AS [CountPCB], N'0' AS [DeviceID], N'' AS [Program], N'263' AS [CycleTime], N'16' AS [NumComp], N'1' AS [NumBlocks], N'0' AS [NumErrors], N'' AS [OrderNo], NULL AS [Operation], N'1' AS [Lane], N'0' AS [SerializedID] UNION ALL
SELECT N'1333017866' AS [PcbID], N'2012-03-29 12:44:26.903' AS [TimeDone], N'5011' AS [McID], N'148' AS [CountPCB], N'0' AS [DeviceID], N'' AS [Program], N'1' AS [CycleTime], N'0' AS [NumComp], N'1' AS [NumBlocks], N'0' AS [NumErrors], N'' AS [OrderNo], NULL AS [Operation], N'1' AS [Lane], N'0' AS [SerializedID]

contestado el 05 de mayo de 13 a las 12:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.