易截截图软件、单文件、免安装、纯绿色、仅160KB

在SQL Server 删除重复数据

删除数据库表中某一字段的重复纪录,只想保留一条记录可用以下方法:
执行以下语句:
declare @max integer,@id varchar(18) --此处变量类型根据字段类型设置
declare cur_rows cursor local for select 字段,count(*) from 表名group by 字段 having count(*) > 1
open cur_rows
fetch cur_rows into @id,@max
while @@fetch_status=0
begin
 select @max = @max -1
 set rowcount @max
 delete from 表名where 字段 = @id
 fetch cur_rows into @id,@max
end
close cur_rows
set rowcount 0


相关文档:

SQL 获取系统文件

--获得当前所有驱动器
exec master.dbo.xp_availablemedia
--获得子目录列表
exec master.dbo.xp_subdirs 'c:\'
--获得所有子目录的目录树结构
exec master.dbo.xp_dirtree 'c:\'
--订阅文件删除
declare @tempTable table (Cont varchar(50))
declare @strTemp varchar(50)
declare @dirPath varchar(50)
declar ......

在sql server中输入'NULL'字符串的有趣发现!

如图1、2,id=1的数据是NULL,其他的为非NULL的数据。
一般情况下,会用两种方法!
方法1.t-sql:insert into E values(1,'NULL'),插入后,在打开表的情况下看到的
是'NULL'(我想是为了区分NULL,才加的引号),但是查询的时候不影响,显示的是NULL,
如图1、2,id为6的数据。
如果要插入带单引号的'NULL',insert i ......

使用SQL*PLUS构建完美excel或html输出

转自:http://hong9270503.blog.163.com/blog/static/127292320091611319516/
通过SQL*PLUS我们可以构建友好的输出,满足多样化用户需求。
  
本例通过简单示例,介绍通过sql*plus输出xls,html两种格式文件.
   首先创建两个脚本:
  
1.main.sql
   用以设置环境,调用具体功能脚本
   2.功能脚本-ge ......

【转】 【SQL】行列转换

【SQL】行列转换
http://space.itpub.net/519536/viewspace-609167
一、列变行
1.创建测试表test,并初始化实验数据
sec@ora10g> create table test (name_id varchar2(10), name varchar2(10));
sec@ora10g> insert into test values ('01','Andy1');
sec@ora10g> insert into test values ('01','Andy2'); ......

SQL求解八皇后问题(92种结果)

--该表保存结果
create table c(c1 tinyint, c2 tinyint, c3 tinyint, c4 tinyint, c5 tinyint, c6 tinyint, c7 tinyint, c8 tinyint, c9 tinyint, c10 tinyint, c11 tinyint, c12 tinyint, c13 tinyint, c14 tinyint, c15 tinyint, c16 tinyint, c17 tinyint, c18 tinyint, c19 tinyint, c20 tinyint, c21 tinyint, c22 t ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号