以这种格式接收了一个数据导入的查询...在SQL中是否有任何等价物只需要使用“insert into blah”一次? (这样我就可以转换这个脚本了)
insert into marital_status (id,description)
values
(1,'Married'),
(2,'Separated'),
(3,'Never Married'),
(4,'Divorced'),
(5,'Widowed'),
(6,'Co-Habitation'),
(7,'No Response')
答案 0 :(得分:5)
这个 是一个T-SQL脚本 - 对于Server 2008 - 不可思议的是,在2005年,你没有这个功能: - (
您需要像这样编写此查询:
insert into marital_status (id,description)
values(1,'Married')
insert into marital_status (id,description)
values(2,'Separated')
insert into marital_status (id,description)
values(3,'Never Married')
insert into marital_status (id,description)
values(4,'Divorced')
insert into marital_status (id,description)
values(5,'Widowed')
insert into marital_status (id,description)
values(6,'Co-Habitation')
insert into marital_status (id,description)
values(7,'No Response')
答案 1 :(得分:3)
另一种选择是:
insert into marital_status (id,description)
SELECT 1,'Married' UNION ALL
SELECT 2,'Separated' UNION ALL
SELECT 3,'Never Married' UNION ALL
SELECT 4,'Divorced' UNION ALL
SELECT 5,'Widowed' UNION ALL
SELECT 6,'Co-Habitation' UNION ALL
SELECT 7,'No Response'