我已经编写了下面的代码并且因错误的语法而不断出现错误
它在,
附近的第10行说 - 所以这一行:
values(1, 'Stolz', 'Ted', 25000, NULL), )
如果我只尝试插入第一行数据,它可以正常工作,那就是当我尝试做多个时。我错过了一些非常简单的东西吗?
Drop Table #TPerson
CREATE TABLE #TPerson
(
personid int PRIMARY KEY NOT NULL,
lastname varchar(50) NULL,
firstname varchar(50) NULL,
salary money NULL,
managerid int NULL
);
Insert Into #TPerson(Personid, lastname, firstname, salary, managerid)
values (1, 'Stolz', 'Ted', 25000, NULL),
(2, 'Boswell', 'Nancy', 23000, 1),
(3, 'Hargett', 'Vincent', 22000, 1),
(4, 'Weekley', 'Kevin', 22000, 3),
(5, 'Metts', 'Geraldine', 22000, 2),
(6, 'McBride', 'Jeffrey', 21000, 2),
(7, 'Xiong', 'Jay', 20000, 3)
答案 0 :(得分:1)
你可以这样写:
Insert Into #TPerson(Personid,lastname,firstname,salary,managerid)
select 1,'Stolz','Ted',25000,NULL
union all select 2,'Boswell','Nancy',23000,1
union all select 3,'Hargett','Vincent',22000,1
union all select 4,'Weekley','Kevin',22000,3
union all select 5,'Metts','Geraldine',22000,2
union all select 6,'McBride','Jeffrey',21000,2
union all select 7,'Xiong','Jay',20000,3