SQL 函数

CREATE FUNCTION [dbo].[fn_Split3](      
 @String nvarchar (max),      
 @Delimiter nvarchar (10) ,
 @Delimiter2 nvarchar (32)      
)      
RETURNS @ValueTable TABLE ([Flag] NVARCHAR(32),[Value] NVARCHAR(max),[id] int)      
BEGIN      
 DECLARE 
  @NextString nvarchar(max), 
  @FlagString nvarchar(32),  
  @ValueString nvarchar(32),     
  @Pos int, 
  @Pos2 int,     
  @NextPos int,      
  @CommaCheck nvarchar(1),    
  @id int    
    
set @id=1      
       
 SET @NextString = '' 
 SET @FlagString = ''
 SET @ValueString = ''
      
 SET @CommaCheck = right(@String,1)       
       
 SET  @String = @String + @Delimiter      
       
  SET @Pos = CHARINDEX(@Delimiter,@String)      
  SET @NextPos = 1      
       
 WHILE (@pos <>  0)        
 BEGIN      
  SET @NextString = SUBSTRING(@String,1,@Pos - 1) 
  
  SET @Pos2 = CHARINDEX(@Delimiter2,@NextString)    
  SET @FlagString = SUBSTRING(@NextString,1,@Pos2 - 1)  
  SET @ValueString = SUBSTRING(@NextString,@Pos2,LEN(@NextString))  
        
  INSERT INTO @ValueTable ( [Flag],[Value],[id]) VALUES (@FlagString,@NextString,@id)      
        
  SET @String = SUBSTRING(@String,@pos +1,LEN(@String))      
         
  SET @NextPos = @Pos      
  SET @pos  = CHARINDEX(@Delimiter,@String)      
    
 set @id = @id +1    
 END      
       
 RETURN      
END  
  

 

 

 

declare @returnSampleValues varchar(max) 
set @returnSampleValues=(select SampleValues from TYcHistory_201707 where SampleTime=(select max(SampleTime) from TYcHistory_201707 where cast(SampleTime as date)='2017/07/06 0:00:00') ) 
SELECT * FROM dbo.[FnSamepleValues](''+@returnSampleValues+'')
where Flag='c112'  

 

posted @ 2017-08-04 15:10  <--青青子衿-->  阅读(147)  评论(0编辑  收藏  举报
// /**/ // 在页脚Html代码 引入 // function btn_donateClick() { var DivPopup = document.getElementById('Div_popup'); var DivMasklayer = document.getElementById('div_masklayer'); DivMasklayer.style.display = 'block'; DivPopup.style.display = 'block'; var h = Div_popup.clientHeight; with (Div_popup.style) { marginTop = -h / 2 + 'px'; } } function MasklayerClick() { var masklayer = document.getElementById('div_masklayer'); var divImg = document.getElementById("Div_popup"); masklayer.style.display = "none"; divImg.style.display = "none"; } setTimeout( function () { document.getElementById('div_masklayer').onclick = MasklayerClick; document.getElementById('btn_donate').onclick = btn_donateClick; var a_gzw = document.getElementById("guanzhuwo"); a_gzw.href = "javascript:void(0);"; $("#guanzhuwo").attr("onclick","follow('33513f9f-ba13-e011-ac81-842b2b196315');"); }, 900);