易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL Select Into语句


SQL Select Into语句
The SELECT INTO Statement
SELECT INTO 语句
The SELECT INTO statement is most often used to create backup copies of tables or for archiving records.
SELECT INTO语句常用来给数据表建立备份或是历史档案。
Syntax
语法
SELECT column_name(s) INTO newtable [IN externaldatabase] from source
Make a Backup Copy
制作一个备份
The following example makes a backup copy of the "Persons" table:
下面的例子中会为"Persons"表制作一个备份
SELECT * INTO Persons_backupfrom Persons
The IN clause can be used to copy tables into another database:
IN子句可以用来将多个数据表拷贝到另一个数据库上:
SELECT Persons.* INTO Persons IN 'Backup.mdb'from Persons
If you only want to copy a few fields, you can do so by listing them after the SELECT statement:
如果你仅仅想拷贝其中的一部分,可以在SELECT后面列举出它们:
SELECT LastName,FirstName INTO Persons_backupfrom Persons
You can also add a WHERE clause. The following example creates a "Persons_backup" table with two columns (FirstName and LastName) by extracting the persons who lives in "Sandnes" from the "Persons" table:
你还可以加上WHERE子句。在下面的举例中会建立一个"Persons_backup"表,里面包含了在"Persons"表中住在"Sandnes"的个人姓(LastName)与名(FirstName)信息。
SELECT LastName,Firstname INTO Persons_backupfrom PersonsWHERE City='Sandnes'
Selecting data from more than one table is also possible. The following example creates a new table "Empl_Ord_backup" that contains data from the two tables Employees and Orders:
选择多个表进行备份也是可以的。下面的举例就建立了一个新的表"Empl_Ord_backup"里面的数据就有Employees和Orders这两张表的内容:
SELECT Employees.Name,Orders.ProductINTO Empl_Ord_backupfrom EmployeesINNER JOIN OrdersON Employees.Employee_ID=Orders.Employee_ID


相关文档:

SQL 2000 無log文件恢復

由于种种原因,我们如果当时仅仅备份了mdf档,那么恢复起来就是一件很麻烦的事情了。
如果您的mdf档是当前资料库产生的,那么很侥幸,也许你使用sp_attach_db或者sp_attach_single_file_db可以恢复资料库,但是会出现类似下面的提示资讯
设备启动错误。物理档案名 'C:\Program Files\Microsoft SQL S ......

VS2010中创建自定义SQL Rule(郝宪玮)

VS2010已经发布几天时间了,一些新的特性特别引人注目,比如: 性能的稳定和提升,表现在WPF GUI和WPF文本呈现。 Windows Azure Tools模板。 多显示器支持,输出窗口,类图窗口,代码定义窗口等提供辅助信息的窗口放置在副显示器中。 对并行计算开发的大量支持。 包含了SharePoint的项目模板和调试支持 ......

SAP 使用SQL Trace(ST05)

SAP 使用SQL Trace(ST05)
SAP R/3 提供标准ABAP SQL 跟踪工具。使用T-Code:ST05 可以进入追踪设定画面:
 
         在Trace Modes 区域中选择需要在SAP R/3 Server 上trace 的范围:
         SQL Trace: 追踪该A ......

sql 列出库中所有表及字段详细信息

--select name from sysobjects where type='U' order by name
SELECT
(case when a.colorder=1 then d.name else '' end) 表名,
-- a.colorder 字段序号,
a.name 字段名,
(case when COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1 then '√'else '' end) 标识,
(case when (SELECT count(* ......

SQL按照日、周、月、年统计数据

如: 表:consume_record 
字段:consume (money类型)  date (datetime类型) 
请问怎么写四条sql语句分别按日,按周,按月,按季统计消费总量. 
如:1月 1200元 
2月 3400元 
3月 2800元 
--按日 
select sum(consume),day([date]) from& ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号