SQL函數集合

1. PATINDEX ( '%pattern%' , expression )sql

返回pattern字符串在表達式expression裏第一次出現的位置,起始值從1開始算。express

pattern字符串在expression表達式裏沒找就返回0,對全部有效的文本和字符串就是有效的數據類型。函數

%使用方法同Likespa

詳細請見:https://msdn.microsoft.com/zh-cn/library/ms188395.aspxcode

2.SUBSTRING ( expression ,start , length )blog

expression爲原字符,start爲開始位置(開始位爲1),length爲長度。字符串

詳細見:https://msdn.microsoft.com/zh-cn/library/ms187748(v=sql.120).aspxstring

兩個函數應用,替換第一位置爲「,」的字符串io

update MainLog set ProductID=substring(ProductID,2,len(productid)-1) where  PATINDEX(',%',ProductID)>0
相關文章
相關標籤/搜索