1. 程式人生 > >SQL Server 中截取字符串常用的函數

SQL Server 中截取字符串常用的函數

site center money sin ima 表達 epo arch rdb

SQL Server 中截取字符串常用的函數:

1.LEFT ( character_expression , integer_expression ) 函數說明:LEFT ( ‘源字符串‘ , ‘要截取最左邊的字符數‘ ) 返回從字符串左邊開始指定個數的字符 select LEFT(‘SQL_Server_2008‘,4 ); 返回結果:SQL_

2.RIGHT ( character_expression , integer_expression ) 函數說明:RIGHT ( ‘源字符串‘ , ‘要截取最右邊的字符數‘ ) 返回字符串中從右邊開始指定個數的 integer_expression 字符 select RIGHT(‘SQL_Server_2008‘,4 ); 返回結果:2008

3.SUBSTRING ( character_expression , start , length ) 函數說明:SUBSTRING ( ‘源字符串‘ , ‘截取起始位置(含該位置上的字符)‘ , ‘截取長度‘ ) 返回字符、binary、text 或 image 表達式的一部分 select SUBSTRING(‘SQL_Server_2008‘,5 ,6); 返回結果:Server

update b set b.typeID=c1.oid,b.brand=c2.oid from BASEINFO_BusVehicles b left join code_content c1 on b.typeID=c1.nameCN
left join code_content c2 on b.brand=c2.nameCN

update a set a.issueMoney=c.depositeMoney * a.issueCount from REPORT_TodayCardBusinessSummary a
left join BUSINESSINFO_ConsumeCards c
on a.cardType=c.cardType where a.rechargeCenterOID=c.rechargeCenterOID and a.terminalsOID=c.terminalsOID and a.cardType =c.cardType
and convert(varchar(10),a.summaryDate,23)=convert(varchar(10),c.issueDate,23) and
a.oid =‘002004810AF543689AE31473F7151538‘


update BUSINESSINFO_todayAnnualSurveyRecords set
nextAnSuValidDate=‘2019-‘+SUBSTRING(convert(varchar(7),annualSurveyDate,23),6,7)+‘-31 00:00:00.000‘

SQL Server 中截取字符串常用的函數