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*/
相关文档:
SQLServer 模式就是,把Session 存放在 SQL Server 数据库里(注意不是 Oracle ,动动脚趾都能猜到原因啦),下面开始说明一下设置的具体步骤:
1、 启动相关的数据库服务(如图)
运行SQL Server 服务管理器 → 启动 SQL Server (最好设为开机自动运行) ......
Oracle笔记
l 关于TRUNC函数
SELECT
RELATED_ID ,
DOC_ID ,
CAT_ID ,
CAT_CODE ,
RELEASE_DATE ,
&n ......
只是sqlserver 提供的远程数据访问函数; 在本地sqlserver 中取外部数据源数据时候可用;
对连接本地 oracle 操作远程 oracle 不能使用; 测试: pl/sql 中使用:
select * from openrowset(................); 无效!!!!!!!!!!!!!!
在oracle 中需要访问远程数据,需要建立一连接远程oracle 的 dblink ;
再用如下方 ......
如果你经常遇到下面的问题,你就要考虑使用SQL Server的模板来写规范的SQL语句了:
SQL初学者。
经常忘记常用的DML或是DDL SQL 语句。
在多人开发维护的SQL中,每个人都有自己的SQL习惯,没有一套统一的规范。
在SQL Server Management Studio中,已经给大家提供了很多常用的现成SQL规范模板。
SQL Server Management ......