---
title: " SQL Server中截取字符串常用函数"
author: "mywhy"
date: "2015-07-21T14:47:25Z"
tags: []
categories: ["数据库"]
slug: "sql-server"
draft: false
lastmod: "2015-07-21T14:47:25Z"
id: 2229058
url: "https://mywhy.iteye.com/blog/2229058"
---

```java
    SQL Server 中截取字符串常用的函数：  
      
    1.LEFT ( character_expression , integer_expression )  
    函数说明：LEFT ( '源字符串' , '要截取最左边的字符数'  )  
    返回从字符串左边开始指定个数的字符  
    select LEFT('12345678',3);  
    返回结果：123  
      
      
    2.RIGHT ( character_expression , integer_expression )  
    函数说明：RIGHT ( '源字符串' , '要截取最右边的字符数'  )  
    返回字符串中从右边开始指定个数的 integer_expression 字符  
    select RIGHT('12345678',3 );  
    返回结果：678  
      
      
    3.SUBSTRING ( character_expression , start , length )  
    函数说明：SUBSTRING ( '源字符串' , '截取起始位置(含该位置上的字符)' , '截取长度' )  
    返回字符、binary、text 或 image 表达式的一部分  
    select SUBSTRING('12345678',2 ,3);  
    返回结果：234  
```