补贴上次面试题# Database - 数据库
n*6
1 楼
Question1: What are the two ways to create the temptable? Which is the best
practice?
My answer:
Option1:
CREATE TABLE ##TEMPTABLE
...
INSERT INTO ##TEMPTABLE
SELECT ...
FROM ...
Option2:
SELECT ...
INTO ##TEMPTABLE
FROM ...
WHERE ...
I do not know which is the best practice. I think both can check the ##
temptable in tempdb first for validation, and both can create index after
data insert.
practice?
My answer:
Option1:
CREATE TABLE ##TEMPTABLE
...
INSERT INTO ##TEMPTABLE
SELECT ...
FROM ...
Option2:
SELECT ...
INTO ##TEMPTABLE
FROM ...
WHERE ...
I do not know which is the best practice. I think both can check the ##
temptable in tempdb first for validation, and both can create index after
data insert.