下面我们再用另外一种传统的插入方法同样添加5行数据,也就是使用带SELECT从句的INSERT SQL语句,脚本如下:
insert into MyTest2 select 1 , 'John' , 'Smith' , 150000.00
insert into MyTest2 select 2 , 'Hillary' , 'Swank' , 250000.00
insert into MyTest2 select 3 , 'Elisa' , 'Smith' , 120000.00
insert into MyTest2 select 4 , 'Liz' , 'Carleno' , 151000.00
insert into MyTest2 select 5 , 'Tony' , 'Mcnamara' , 150300.00
执行结果如下:
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
方法三
同样的,我们再假设上述的MyTestDB数据库中有表MyTest3,如下:
| USE [MyTestDB] GO IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MyTest3]') AND type in (N'U')) DROP TABLE [dbo].[MyTest3] GO USE [MyTestDB] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[MyTest3]( [Id] [int] NULL, [Fname] [varchar](100) NULL, [Lname] [varchar](100) NULL, [salary] [money] NULL ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO |

