SQLServer数据集合的交、并、差集运算
SQLServer2005通过intersect,union,except和三个关键字对应交、并、差三种集合运算。
他们的对应关系可以参考下面图示
相关测试实例如下:
use tempdb
go
if (object_id ('t1' ) is not null ) drop table t1
if (object_id ('t2' ) is not null ) drop table t2
go
create table t1 (a int )
insert into t1 select 1 union select 2 union select 3
create table t2 (a int )
insert into t2 select 3 union select 4 union select 5
go
select * from t1 union select * from t2
go
/* 求表并集
1
2
3
4
5*/
select * from t1 union all select * from t2
go
/*求表并集不过滤重复
1
2
3
3
4
5*/
select * from t1 except select * from t2
go
/*求t1对t2的差集
1
2*/
select * from t1 intersect select * from t2
go
/*求t1对t2的交集
3*/
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jinjazz/archive/2009/09/07/4527863.aspx
相关文档:
if (object_id ('t' ) is not null ) drop table t
go
create table t (id int identity (1 , 1 ), name varchar (40 ))
go
insert into t (name ) select newid ()
go 10
select * from t
/*
1 18C1C418-9029-4599-8D5E-616354A113C8
2 A0FE1177-09D8-4C56-9FB5-C2FA ......
SQLServer2005分解并导入xml文件 收藏
测试环境SQL2005,windows2003
DECLARE @idoc int;
DECLARE @doc xml;
SELECT @doc=bulkcolumn from OPENROWSET(
BULK 'D: \test.xml',
SINGLE_BLOB) AS x
EXEC sp_xml_preparedocument @Idoc OUTPUT, @doc
......
最近整理出来的.如果不完全的话希望大家补充.
在access中,转换为大写的sql函数是ucase,在sqlserver中,转换为大写的函数是upper;在access中,转换为小写的函数是lcase,在sqlserver中,转换为小写的函数是lower;在access中,取当前时间的函数是now,另外还有一个取日期函数date,在sqlserver中,取当前的函数是getdate ......
原文转自:http://dev.csdn.net/develop/article/71/71778.shtm
大多数SQL Server表需要索引来提高数据的访问速度,如果没有索引,SQL Server要进行表格扫描读取表中的每一个记录才能找到索要的数据。索引可以分为簇索引和非簇索引,簇索引通过重排表中的数据来提高数据的访问速度,而非簇索引则通过维护表中的数 ......