Tuesday, 14 May 2013

Select PatIndex,CharIndex,Replace,Substring Using Sql

Select PatIndex,CharIndex,Replace,Substring Using Sql


//Select Content:

  Select Content From Char_Index



//CHARINDEX:

  Select CharIndex('src',Content) as CharIndex From Char_Index 



//SUBSTRING:

  Select SUBSTRING(content,101,60) as SubString From Char_Index

   


//Substring and CharIndex:

 SELECT SUBSTRING(content, CHARINDEX('src', content)+5,   
 CHARINDEX('png', content) - CHARINDEX('src', content)) as Image
 From  Char_Index


//Replace-Substring:

  Select REPLACE(SUBSTRING(content, CHARINDEX('src', content)+5,    
  CHARINDEX('png', content) - CHARINDEX('src', content)),'"','') 
  as Image From Char_Index





No comments:

Post a Comment