zoukankan      html  css  js  c++  java
  • 2008年10月小记(SQL删除重复记录,生成表结构,字符串特性,statistics io)

    1、删除某字段中的重复记录,Table1006表中有Id和Phone字段,Id为不重复的标字段,但是Phone含有重复字段,现在需要重复Phone记录行删除掉,只保留最新一条记录。
        if OBJECT_ID('dbo.Table1006'is not null
            
    drop table dbo.Table1006
        
    create table dbo.Table1006
        (
            
    [Id] int,
            
    [Phone] varchar(10)
        )
        
    insert into dbo.Table1006 values(1100)
        
    insert into dbo.Table1006 values(2110)
        
    insert into dbo.Table1006 values(3120)
        
    insert into dbo.Table1006 values(4130)
        
    insert into dbo.Table1006 values(5110)
        
    insert into dbo.Table1006 values(6110);
        
    insert into dbo.Table1006 values(7120);
        
        
    delete from dbo.Table1006 
            
    where [Id] not in ( select  max([Id]as [Id] 
                
    from dbo.Table1006 
                
    group by [Phone])
        
    select * from dbo.Table1006

        
    drop table dbo.Table1006


    2、 生成表结构(可贴到Excel)方便编辑。

    T-SQL

    运行SQL语句,然后把Messages贴到Excel中就能方便的对结构进行编辑了。

    3、字符串特性。
    字符串具有恒定性、字符串驻留(跨AppDomain)、参数传递的特殊性。

    Code

    4、statistics io
    set statistics io on 
    set statistics io off


  • 相关阅读:
    JAVA多线程实现的三种方式
    Java String charAt()方法
    三大数据库分页方法
    SSH框架 spring 配置中的: scope="prototype"
    SSH中的Invalid action class configuration that references an unknown class named.......
    String类中toCharArray()方法的用法
    SQL Server中DateTime与DateTime2的区别
    Java 集合系列11之 Hashtable详细介绍(源码解析)和使用示例
    Java 集合系列10之 HashMap详细介绍(源码解析)和使用示例
    哈希表及处理冲突的方法
  • 原文地址:https://www.cnblogs.com/chenjunbiao/p/1760194.html
Copyright © 2011-2022 走看看