时间:2021-07-01 10:21:17 帮助过:16人阅读
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 中截取字符串常用的函数
标签:record 表达式 0.00 where roi card eid 截取 rds