这是创建一个temptable并用选定的数据填充它 现有的地址表;之后我想要显示 temptable(即选择*并显示它)
这是我的代码,但它有一些小问题。 有谁知道如何编写它以便正确运行?
CREATE TABLE #Address
(
AddressID int,
AddressLine1 nvarchar(60),
City nvarchar(30),
)
SELECT AddressID,AddressLine1
INTO #Address
FROM [Person].[Address]
WHERE AddressLine1 LIKE '%Drive%' AND AddressID BETWEEN 400 and 1000
SELECT *
FROM
#Address
答案 0 :(得分:2)
由于您已创建表,因此必须使用insert into,而不是select into。通常,select into用于创建包含数据的表:
insert into #address (addressid, addressline1)
select addressid, addressline1
from Address
where AddressLine1 LIKE '%Drive%' AND AddressID BETWEEN 400 and 1000