Select into from a history table
- Last UpdatedMar 19, 2025
- 1 minute read
The following query inserts the specified data from the WideHistory table into another table called MyTable. Then, the data in the MyTable table is queried. This query uses the OPENQUERY function.
DROP TABLE MyTable
SELECT DateTime,
"Sec" = datepart(ss, DateTime),
"mS" = datepart(ms, DateTime),
ReactTemp, ReactLevel
INTO MyTable
FROM OpenQuery(INSQL, 'SELECT DateTime, ReactTemp, ReactLevel FROM WideHistory
WHERE wwResolution = 5000
AND DateTime >= "2001-03-13 1:58pm"
AND DateTime <= "2001-03-13 2:00pm" ')
SELECT * FROM MyTable
The results are:
|
DateTime |
Sec |
mS |
ReactTemp |
ReactLevel |
|
2001-03-13 13:58:00.000 |
0 |
0 |
190.9 |
2025.0 |
|
2001-03-13 13:58:00.000 |
5 |
0 |
190.9 |
2025.0 |
|
2001-03-13 13:58:00.000 |
10 |
0 |
168.3 |
1215.0 |
|
2001-03-13 13:58:00.000 |
15 |
0 |
168.3 |
1215.0 |
|
2001-03-13 13:58:00.000 |
20 |
0 |
133.8 |
315.0 |
|
2001-03-13 13:58:00.000 |
25 |
0 |
133.8 |
315.0 |
|
2001-03-13 13:58:00.000 |
30 |
0 |
101.6 |
0.0 |
|
2001-03-13 13:58:00.000 |
35 |
0 |
101.6 |
0.0 |
|
2001-03-13 13:58:00.000 |
40 |
0 |
32.4 |
750.0 |
|
2001-03-13 13:58:00.000 |
45 |
0 |
32.4 |
750.0 |
|
2001-03-13 13:58:00.000 |
50 |
0 |
20.9 |
1700.0 |
|
2001-03-13 13:58:00.000 |
55 |
0 |
20.9 |
1700.0 |
|
2001-03-13 13:59:00.000 |
0 |
0 |
85.9 |
2000.0 |
|
2001-03-13 13:59:00.000 |
5 |
0 |
85.9 |
2000.0 |
|
2001-03-13 13:59:00.000 |
10 |
0 |
185.9 |
2000.0 |
|
2001-03-13 13:59:00.000 |
15 |
0 |
185.9 |
2000.0 |
|
2001-03-13 13:59:00.000 |
20 |
0 |
168.3 |
1235.0 |
|
2001-03-13 13:59:00.000 |
25 |
0 |
168.3 |
1235.0 |
|
2001-03-13 13:59:00.000 |
30 |
0 |
136.1 |
335.0 |
|
2001-03-13 13:59:00.000 |
35 |
0 |
136.1 |
335.0 |
|
2001-03-13 13:59:00.000 |
40 |
0 |
103.9 |
-25.0 |
|
2001-03-13 13:59:00.000 |
45 |
0 |
103.9 |
-25.0 |
|
2001-03-13 13:59:00.000 |
50 |
0 |
34.7 |
625.0 |
|
2001-03-13 13:59:00.000 |
55 |
0 |
34.7 |
625.0 |
|
2001-03-13 14:00:00.000 |
0 |
0 |
20.9 |
1575.0 |
(25 row(s) affected)