少用且有用的SQL语句

1.waitfor

--例 等待1 小时2 分零3 秒后才执行SELECT 语句

waitfor delay '01:02:03'
select * from employee

--例 等到晚上11 点零8 分后才执行SELECT 语句

waitfor time '23:08:00'
select * from employee


2.查看sqlserver版本

select serverproperty('productversion'),serverproperty('productlevel'),serverproperty('edition')


5.SQL语句附加数据库

use master
EXEC sp_attach_db @dbname = N'pubs',
@filename1 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs.mdf',
@filename2 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs_log.ldf'


6.数据库表间数据复制

--1.表结构相同的表,且在同一数据库(如,table1,table2)

Sql :insert into table1 select * from table2 (完全复制)

insert into table1 select distinct * from table2(不复制重复纪录)

insert into table1 select top 5 * from table2 (前五条纪录)


7.按姓氏笔画排序

Select * From TableName Order By CustomerName Collate Chinese_PRC_Stroke_ci_as

Tag标签: 常用方法
posted on 2009-04-28 21:19 发布:水寒冰 阅读(599) 评论(1) 收藏 所属分类: SQL
Poon
『2009-04-29 17:58』

有用,有用!

  • 评论
  • 点击刷新
  • [使用Ctrl+Enter键可以直接提交]

表情图标

[smile][confused][cool][cry][eek][angry][wink][sweat][lol][stun][razz][redface][rolleyes][sad][yes][no][heart][star][music][idea]
Advertise
Category
Time Counter

离十一还有

Recent Article
Statistics
Recent Comments
Archive
Links
Support
《良机》 鲜果阅读器订阅图标
 
TOP