自己再顶一下,是内容太多还是没说清楚?欢迎指正。
解决方案 »
- 请教个SQL问题
- 求教各位高手一道SQL语句。谢谢了。
- 请问,怎么得到表中的所有字段的字段名,字段类型,长度,还有属性说明呀???
- 高手进================解
- 没有分了,谁帮我
- 怎样写查询语句?有一个表中有近20个字段存储的是代码值,但是在DBGridEH中显示时需要将这些字段显示为其名称,而这20个字段的代码和名称值分别放在20个表中,并且这些字段在DBGridEh中显示的位置是不固定的
- 高手请进!!关于转移数据的问题
- 调用dts包,在存储过程中dtsrun 如何写
- 求一句简单的SQL语句,SQL非菜鸟级达人入~~~~
- 如何在win2000下通过SQLserver copy文件
- 求一MDX语句,急!!!!
- 如何删除SQL 2000 server ?
/*
标题:取得最小的断号
作者:爱新觉罗.毓华
时间:2008-05-22
地点:广东深圳
*/create table Account(Accountid int)insert into Account values(1)
insert into Account values(2)
insert into Account values(5)--方法一
select min_Accountid = min(m.Accountid) + 1 from
(
select * , px = (select count(1) from account where Accountid < t.Accountid) + 1 from Account t
) m,
(
select * , px = (select count(1) from account where Accountid < t.Accountid) + 1 from Account t
) n
where m.px = n.px - 1 and m.accountid <> n.accountid - 1/*
min_Accountid
-------------
3(所影响的行数为 1 行)
*/--方法二
SELECT CASE WHEN NOT EXISTS(SELECT * FROM Account WHERE Accountid = 1) THEN 1
ELSE MIN(Accountid) + 1
END as min_Accountid
FROM Account AS A
WHERE NOT EXISTS (SELECT * FROM Account AS B WHERE B.Accountid = A.Accountid + 1) /*
min_Accountid
-------------
3(所影响的行数为 1 行)
*/drop table Account