首页   |   IT资讯   |   综合资讯   |   开发   |   软件   |   问答   |   网络技术   |   网络综合
更多:
当前位置:首页 » 手机数码
文章正文

高难度问题,高分求解?得到一个字符串中的字符!

类型:转载   责任编辑:asp   日期:2007/03/01

    

有一字符串:       aaa#bbb#1234#werwer#asdfsdf  
  现在要在sqlserver   7中根据一个变量i得到x的值如下:  
  i=1  
  x=aaa  
   
  i=2  
  x=bbb  
   
  i=3  
  x=1234  
   
  ......  
  求解?

推荐阅读

  • 享受摄影 享受自由 尼康P1试用报告 [详细内容]
  • 预测2006:液晶逼退等离子 大屏幕液晶将降30% [详细内容]
  • 决战高端宝座:英特尔Pentium EE 965详测 [详细内容]
  • 力与美!体坛小姐诱惑走光图(图) [详细内容]
  • 竟和唐国强相似 电脑复原康熙大帝真面目(图) [详细内容]
  • 英特尔如何修炼成坐山赚虎斗的本领 [详细内容]
  • 答复ttto的问题,兼谈5238 [详细内容]
  • 网友回答:
    网友:happydreamer

    create   function   getstrofindex   (@str   varchar(8000),@index   int   =0)  
      returns   varchar(8000)  
      as  
      begin  
          declare   @str_return   varchar(8000)  
          declare   @start   int  
          declare   @next   int  
          declare   @location   int  
          select   @start   =1  
          select   @next   =1  
          select   @location   =   charindex(#,@str,@start)  
          while   (@location   <>0   and   @index   >   @next   )  
          begin  
              select   @start   =   @location   +1  
              select   @location   =   charindex(#,@str,@start)  
              select   @next   =@next   +1  
          end  
          if   @location   =0   select   @location   =len(@str)+1    
          select   @str_return   =   substring(@str,@start,@location   -@start)  
          if   (@index   <>   @next   )   select   @str_return   =      
          return   @str_return  
      end  
      go  
      select   dbo.getstrofindex(aaa#bbb#1234#werwer#asdfsdf  
      ,3)  
     

    .
      最佳浏览:1024X768 MSIE
    ©2007 jqmk.com.cn All Rights Reserved