易截截图软件、单文件、免安装、纯绿色、仅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 Server2000 解析XML

DECLARE @HDOC INT --文档句柄
DECLARE @XMLSTRING VARCHAR(200) --XML字符串
SET @xmlString ='<?xml version="1.0"?>
<ROOT>
<USER ID="1" Name="SBQCEL"/>
<USER ID="2" Name="PEACELI"/>
<USER ID="3" Name="SHEEPCHANG"/>
</ROOT>'
--使用系统存储 ......

sql server分布式事务解决方案

适用环境
操作系统:windows 2003
数据库:sql server 2000/sql server 2005
使用链接服务器进行远程数据库访问的情况
一、  问题现象
在执行分布式事务时,在sql server 2005下收到如下错误:
消息 7391,级别 16,状态 2,过程 xxxxx,第 16 行
无法执行该操作,因为链接服务器 "xxxxx" 的 OLE DB 访问接口 " ......

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 ......

基于SQL的分页

select top PageSize * from 表
where 条件 and id not in
(select top PageSize*(CurrentPageIndex-1)  id from 表 where 条件 order by 排序条件)
order by 排序条件
《PageSize 是GridView中每页显示的信息条数,PageSize*(CurrentPageIndex-1) 在SQL中不识别,需定义变量来替换》 ......

sql经典语句

SQL分类:
DDL—数据定义语言(CREATE,ALTER,DROP,DECLARE)
DML—数据操纵语言(SELECT,DELETE,UPDATE,INSERT)
DCL—数据控制语言(GRANT,REVOKE,COMMIT,ROLLBACK)
首先,简要介绍基础语句:
1、说明:创建数据库
CREATE DATABASE database-name
2、说明:删除数据库
drop database dbname ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号