SQL Server 2008之行值构造器

来源:中国IT实验室 作者:佚名 2008-05-07 出处:pcdog.com

sql server  数据库  
上一页 1 2 3 4 5 下一页 

    下面我们再用另外一种传统的插入方法同样添加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


更多内容请看PCdog.com--SQL Server专题
上一页 1 2 3 4 5 下一页 
上一篇:SQL Server中数据导入导出三种方法
下一篇:SQL Server事务日志的几个常用操作