zoukankan      html  css  js  c++  java
  • 挖掘表字段中的汉字 上海

    在写新版块的时候,碰到一个小问题,新闻是生成静态HTML的,表NEWS中的CONTENT是新闻的内容,在前台,显示图片新闻的同时,要显示一些新闻内容的简介,CONTENT 字段里面有许多的标记符或其他符号,
    为此,特写了个小函数实现
    -- =============================================
    -- Author:  <Author,OldA>
    -- Create date: <Create Date, ,>
    -- Description: <Description, ,>
    -- =============================================
    ALTER  function [dbo].[fn_GetChinese] (@str varchar(4000))
     returns varchar(100)
     as
      begin
        declare @i int ,@itmp int
         select @i=1
         while @i<=len(@str)
          begin
          select @itmp=convert(int,substring(convert(varbinary,substring(@str,@i,1)),1,1))
           if @itmp>127
            begin
               break
             end
          select @i=@i+1     
         end
         select @str=substring(@str,@i,100)
           select @itmp=charindex('<',@str)
                if @itmp>0
                   begin
                    select @str=substring(@str,0,@itmp)
                   end 
        return @str
        end
    。。。。。。。。由于项目时间的仓促,并没做过多的测试,希望看官在性能上或其他方面,提点意见!

  • 相关阅读:
    PlantUML —— 应用于 Eclipse 的简单快速的 UML 编辑软件
    PlantUML类图
    Java 基于log4j的日志工具类
    RabbitMQ Hello world(二)
    redis lua 初体验
    mysql 批处理 innodb_flush_at_trx_commit 测试分析
    mysql 服务日志 5.7.29
    redis 浅谈事务
    redis list 基本操作
    redis hash 基本操作
  • 原文地址:https://www.cnblogs.com/luozhai714/p/738814.html
Copyright © 2011-2022 走看看