02 2010 档案
Sql Server中你可能不知道的统计记录数量的count函数
摘要:我们都知道,Count函数即可以像其他聚合函数一样使用字段名做为参数, 也可以使用星号(*) 做为参数,如:select Count(*) from UserList与select Count(UserName) from UserList,执行结果为100及100,执行结果一样。因为数据库设计为UserName为非空字段。假如该表中有另外一个字段,TelphoneNumber,该字段可为NULL... 阅读全文
posted @ 2010-02-09 15:04 dongpo 阅读(773) 评论(0) 推荐(0)
SQL Server中删除重复数据的几个方法详解
摘要:方法一declare @max integer,@id integerdeclare cur_rows cursor local for select 主字段,count(*) from 表名 group by 主字段 having count(*) > 1open cur_rowsfetch cur_rows into @id,@maxwhile @@fetch_status=0begin... 阅读全文
posted @ 2010-02-08 15:49 dongpo 阅读(243) 评论(0) 推荐(0)
SQL Server中删除重复数据最快的方法详解
摘要:由于种种原因,在数据库中出现了我们不希望出现的重复数据,当对这些重复的数据进行删除的时候有许多种方法。我发现在网上流行的一种方法是利用临时表的方法,SQL脚本如下: select distinct * into #Tmp from tableName drop table tableName select * into tableName from #Tmp drop table #Tmp  该方... 阅读全文
posted @ 2010-02-08 15:45 dongpo 阅读(277) 评论(0) 推荐(0)
在SQL Server和Access中清空表并重新开始编号的方法
摘要:SQL Server: Truncate是SQL中的一个删除数据表内容的语句,用法是:   语法   TRUNCATE TABLE name   参数   name   是要截断的表的名称或要删除其全部行的表的名称。   下面是对Truncate语句在MSSQLServer2000中用法和原理的说明:   Truncate table 表名 速度快,而且效率高,因为:   TRUNCATE T... 阅读全文
posted @ 2010-02-02 10:38 dongpo 阅读(4139) 评论(0) 推荐(0)