如题:示例:原列列1
2
3
4
8
1
结果:列1
1
2
3
4
8输出:5,6,7不存在这个sql怎么写?
2
3
4
8
1
结果:列1
1
2
3
4
8输出:5,6,7不存在这个sql怎么写?
解决方案 »
- 由于回复较多,贴子已结,但还是不解,故发贴再问。
- SqlServer中的数据类型UniqueIdentifier到底是什么东东?
- 还是关于刚才触发器的问题,刚才那位大哥(当然欢迎各位高手)进.
- SQL表与表同步急。
- 不好意思,再问一下!
- 一个简单的数据库问题
- 请问如何把一个 Access 数据库 迁移/升级/转换/搞 成 SQL Server 2005 版的?
- 我的多表更新触发器错哪了?
- SQL server 非常难的问题?
- 我的bcp为什么会出错?
- 数据库连接的怪现象
- 关于数据库An internal error occurred during:" Generating Artifacts"的问题?
-- Author :fredrickhu(小F,向高手学习)
-- Date :2010-05-28 09:44:17
-- Version:
-- Microsoft SQL Server 2005 - 9.00.4035.00 (Intel X86)
-- Nov 24 2008 13:01:59
-- Copyright (c) 1988-2005 Microsoft Corporation
-- Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 3)
--
----------------------------------------------------------------
--> 测试数据:[tb]
if object_id('[tb]') is not null drop table [tb]
go
create table [tb]([列1] int)
insert [tb]
select 2 union all
select 3 union all
select 4 union all
select 8 union all
select 1
--------------开始查询--------------------------select number from master..spt_values where number between 1 and 8 and type='p' and number not in(select [列1] from tb)
----------------结果----------------------------
/* number
-----------
5
6
7(3 行受影响)
*/
where not exists (select * from t b
where b.id=t.id+1) ;
输出是个断号的范围
select id+1,(select min(id)-1 from t c where c.id>id+1) from t a
where not exists (select * from t b
where b.id=a.id+1) ;