新手在这里。我试图在sql server中执行这一行:
CREATE TABLE dummy_driver
但我在
附加代码行:
INSERT INTO Person (first_name, last_name)
Select f_name, l_name FROM driver;
CREATE TABLE dummy_driver
INSERT INTO dummy_driver
Select * from driver;
答案 0 :(得分:5)
您需要在Create语句中为表定义列。您的TSQL应如下所示:
INSERT INTO Person (first_name, last_name)
Select f_name, l_name FROM driver;
CREATE TABLE dummy_driver (First_Name varchar(25), last_name varchar(25))
INSERT INTO dummy_driver
Select first_name, last_name from driver;
您还可以使用Select Into:
动态创建表格SELECT first_name, last_name into dummy_driver
FROM driver
答案 1 :(得分:0)
我可以看到您希望将整个架构和数据从driver
复制到dummy_driver
。您可以简单地写为:
Create Table
编写dummy_driver
语句
SELECT * INTO dummy_driver FROM driver
答案 2 :(得分:-1)
如果您只是从driver
选择所有列到dummy_driver
,您也可以像这样创建:
create table dummy_driver like driver;
insert into dummy_driver select * from driver;