卒子's profile╰☆╮浪子心声╭☆╯PhotosBlogListsMore Tools Help

Blog


    系统垃圾清理

        贴一个大家都用到的东西吧,清理电脑垃圾文件用的。
        别说我火星,因为它太有用了,只要用电脑这个东西就闲不着,而且很方面。双击一下系统干干净净(不会清理注册表,请放心使用)
     
    @echo off
    echo 正在清除系统垃圾文件,请稍等......
    del /f /s /q %systemdrive%\*.tmp
    del /f /s /q %systemdrive%\*._mp
    del /f /s /q %systemdrive%\*.log
    del /f /s /q %systemdrive%\*.gid
    del /f /s /q %systemdrive%\*.chk
    del /f /s /q %systemdrive%\*.old
    del /f /s /q %systemdrive%\recycled\*.*
    del /f /s /q %windir%\*.bak
    del /f /s /q %windir%\prefetch\*.*
    rd /s /q %windir%\temp & md %windir%\temp
    del /f /q %userprofile%\cookies\*.*
    del /f /q %userprofile%\recent\*.*
    del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
    del /f /s /q "%userprofile%\Local Settings\Temp\*.*"
    del /f /s /q "%userprofile%\recent\*.*"
    echo 清除系统LJ完成,谢谢使用!
    echo. & pause
     
     
    使用方法:
         把上面那段代码复制下来放到一个文本文件里面,把文本文件重命名为“清理.bat”(主要是后缀名不能变,别告诉我不知道怎么改后缀名),什么时候想清理电脑垃圾就把这个文件双击一下,简单吧。
         强人写的,就是dos下的一段批处理命令,把系统分区下不用的文件删掉,仔细看一下就会明白
     
     

     

    SQL Server数据迁移

           前段时间向Oracle迁移数据,着实费了不少劲,用尽各种方法,查了很多资料总算搞定。不过战果还算辉煌,积累了部分经验,也留下了一下珍贵资料,今天翻电脑时看到一个很好的存储过程,可以直接生成SQL语句,操作起来相当方面。不过他不适合表比较多的数据库,如果有几百张表还是考虑其他方法吧

           看不懂没关系,拿过去直接用就是,具体实现如下

     
    create       PROCEDURE   dbo.UspOutputData  
      @tablename   sysname  
      AS  
      declare   @column   varchar(1000)  
      declare   @columndata   varchar(1000)  
      declare   @sql   varchar(4000)  
      declare   @xtype   tinyint  
      declare   @name   sysname  
      declare   @objectId   int  
      declare   @objectname   sysname  
      declare   @ident   int  
       
      set   nocount   on  
      set   @objectId=object_id(@tablename)  
       
      if   @objectId   is   null   --   判断对象是否存在    
      begin    
      print   'The   object   not   exists'    
      return    
      end    
      set     @objectname=object_name(@objectId)  
       
      if     @objectname   is   null   or   charindex(@objectname,@tablename)=0   --此判断不严密  
      begin  
      print   'object   not   in   current   database'  
      return  
      end  
       
      if   OBJECTPROPERTY(@objectId,'IsTable')   <>   1   --   判断对象是否是table    
      begin    
      print   'The   object   is   not   table'    
      return    
      end    
       
      select   @ident=status&0x80     from   syscolumns   where  
    id=@objectid   and   status&0x80=0x80  
       
      if   @ident   is   not   null  
      print   'SET   IDENTITY_INSERT  
    '+@TableName+'   ON'  
       
      declare   syscolumns_cursor   cursor    
      for   select   c.name,c.xtype   from   syscolumns   c  
      where  
    c.id=@objectid  
      order   by   c.colid  
      open   syscolumns_cursor  
      set   @column=''  
      set   @columndata=''  
      fetch   next   from   syscolumns_cursor   into   @name,@xtype  
      while   @@fetch_status   <>-1  
      begin  
      if   @@fetch_status<>-2  
      begin  
      if   @xtype   not   in(189,34,35,99,98)   --timestamp不需处理,image,text,ntext,sql_variant   暂时不处理  
      begin  
      set   @column=@column+case   when   len(@column)=0   then''   else   ','end+@name  
      set   @columndata=@columndata+case   when   len(@columndata)=0   then   ''   else   ','','','end  
      +case   when   @xtype   in(167,175)   then  
    '''''''''+'+@name+'+'''''''''   --varchar,char  
      when   @xtype   in(231,239)   then  
    '''N''''''+'+@name+'+'''''''''   --nvarchar,nchar  
      when   @xtype=61   then   '''''''''+convert(char(23),'+@name+',121)+'''''''''   --datetime  
      when   @xtype=58   then   '''''''''+convert(char(16),'+@name+',120)+'''''''''   --smalldatetime  
      when   @xtype=36   then   '''''''''+convert(char(36),'+@name+')+'''''''''   --uniqueidentifier  
      else   @name   end  
      end  
      end      
      fetch   next   from   syscolumns_cursor   into   @name,@xtype  
      end  
      close   syscolumns_cursor  
      deallocate   syscolumns_cursor  
       
      set   @sql='set   nocount   on   select   ''insert  
    '+@tablename+'('+@column+')   values(''as   ''--'','+@columndata+','');''   from   '+@tablename   --此处生产语句,根据需要随便扩展
        
      print  
    '--'+@sql  
      exec(@sql)  
       
      if   @ident   is   not   null  
      print   'SET   IDENTITY_INSERT  
    '+@TableName+'   OFF'  
       
      GO  

    --执行方法 exec UspOutputData (tablename)
    --用于sqlserver中,复制产生脚本可以直接插入数据库中


    IT

    怎么说自己也算个it人吧,突然发现这里竟然找不到一点影子,好像不太正常。生活的经历不太好说,就记录工作的点点滴滴吧,多写点技术文章,不管看到的还是想到的就当一次学习经历吧。为别人更为自己   ^_^