1

你好我有一个初学者问题

我收到了以下声明

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

我现在如何将我拥有的所有东西 #tmp_GridResults_1插入到某个表中?

4

1 回答 1

1

我认为您不需要将记录放在变量中,因为您可以直接在另一个表上插入记录。

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]
于 2013-05-05T11:31:22.937 回答