Where 1 = 2 is called for each row?

I have sprocs that need a temp table. In order not to recode the column types (which are varchar with a certain length), so I do not need to change the declarations when changing the link table schema (i.e. the fields become longer). I do this (instead of calling the create table):

select orderId
into #sometmptbl
from orders
where 1=2

However, when you do showplan on this, it actually looks like a table / index:

APPLICATION REQUEST PLAN 1 (on line 1).

STEP 1
    The type of query is CREATE TABLE.

STEP 2
    The type of query is INSERT.
    The update mode is direct.

    FROM TABLE
        orders
    Nested iteration.
    Index : orders_idx1
    Forward scan.
    Positioning at index start.
    Index contains all needed columns. Base table will not be read.
    Using I/O Size 2 Kbytes for index leaf pages.
    With LRU Buffer Replacement Strategy for index leaf pages.
    TO TABLE
        #sometmptbl
    Using I/O Size 2 Kbytes for data pages.

Total estimated I / O cost for operator 1 (line 1): 632082.

Does this mean that 1 = 2 is evaluated for each record in the index? Is there a way to do this for a constant time?

Update

- , , 0, :

Table: orders scan count 0, logical reads: (regular=0 apf=0 total=0), physical reads: (regular=0 apf=0 total=0), apf IOs used=0
Table: #sometmptbl_____00002860018595346 scan count 0, logical reads: (regular=1 apf=0 total=1), physical reads: (regular=0 apf=0 total=0), apf IOs used=0
Total actual I/O cost for this command: 2.
Total writes for this command: 3
0 row(s) affected.
+5
2

io on, . , , , .

. , ( ). ( temp).

- 1 = 2 tempdb..MyScratchTable, RapidSQL ( - ) DDL .

varchar, , .

+4

select orderId from orders where 1=2?

, .., ( INTO) / .

0

All Articles