/************************************************************************/ /* 程序编写: Jeff 版 本: V 1.0 建立日期: 2015-06-02 功能说明: 查找字段记录最长字符数; 备 注: 修改日期: 修改说明: */ /************************************************************************/ use [db] declare @len int select @len = max(len([count])) from dindansp3 select * from dindansp3 where len([count]) = @len --删除[lonindata]表中多余的重复记录,并创建约束; use [db] select identity(int,1,1) as autoid, * into #temp1 from [lonindata] select min(autoid) as autoid into #temp2 from #temp1 group by [no],[datetime] truncate table [lonindata] insert into [db].[dbo].[lonindata]([no],[datetime]) select [no],[datetime] from #temp1 where autoid in(select autoid from #temp2) order by [no] drop table #temp1 drop table #temp2