Sql Server REPLACE函数

本文涉及的产品
云数据库 RDS SQL Server,独享型 2核4GB
RDS SQL Server Serverless,2-4RCU 50GB 3个月
推荐场景:
简介: Replaces all occurrences of a specified string value with another string value. 语法: REPLACE ( string_expression , string_pattern , string_replacement ) 参数: string_expression Is the string exp

Replaces all occurrences of a specified string value with another string value.
语法:
REPLACE ( string_expression , string_pattern , string_replacement )
参数:
string_expression
Is the string expression to be searched. string_expression can be of a character or binary data type.
string_pattern
Is the substring to be found. string_pattern can be of a character or binary data type. string_pattern cannot be an empty string (''), and must not exceed the maximum number of bytes that fits on a page.
string_replacement
Is the replacement string. string_replacement can be of a character or binary data type.
返回
Returns nvarchar if one of the input arguments is of the nvarchar data type; otherwise, REPLACE returns varchar.
Returns NULL if any one of the arguments is NULL.
If string_expression is not of type varchar(max) or nvarchar(max), REPLACE truncates the return value at 8,000 bytes. To return values greater than 8,000 bytes, string_expression must be explicitly cast to a large-value data type.
即用第三个表达式替换第一个字符串表达式中出现的所有第二个给定字符串表达式。

例子:

SELECT REPLACE('AAAAAXXXAAA','X','A');

结果:

 

 

相关实践学习
使用SQL语句管理索引
本次实验主要介绍如何在RDS-SQLServer数据库中,使用SQL语句管理索引。
SQL Server on Linux入门教程
SQL Server数据库一直只提供Windows下的版本。2016年微软宣布推出可运行在Linux系统下的SQL Server数据库,该版本目前还是早期预览版本。本课程主要介绍SQLServer On Linux的基本知识。 相关的阿里云产品:云数据库RDS SQL Server版 RDS SQL Server不仅拥有高可用架构和任意时间点的数据恢复功能,强力支撑各种企业应用,同时也包含了微软的License费用,减少额外支出。 了解产品详情: https://www.aliyun.com/product/rds/sqlserver
目录
相关文章
|
8天前
|
SQL XML 关系型数据库
【less-5】基于SQLI的SQL盲注常用函数
【less-5】基于SQLI的SQL盲注常用函数
19 2
|
3天前
|
SQL Oracle 关系型数据库
SQL LAST() 函数
SQL LAST() 函数
12 5
|
4天前
|
SQL Oracle 关系型数据库
SQL FIRST() 函数
SQL FIRST() 函数
10 3
|
4天前
|
SQL Oracle 关系型数据库
SQL COUNT() 函数
SQL COUNT() 函数
9 3
|
4天前
|
SQL 数据库
SQL AVG() 函数
SQL AVG() 函数
10 2
|
5天前
|
SQL 关系型数据库 MySQL
SQL 函数
SQL 函数
28 3
|
6天前
|
SQL 存储 关系型数据库
SQL Date 函数
SQL Date 函数
26 3
|
6天前
|
SQL Oracle 关系型数据库
SQL NULL 函数
SQL NULL 函数
16 1
|
19天前
|
SQL 关系型数据库 MySQL
MySQL数据库——基础篇总结(概述、SQL、函数、约束、多表查询、事务)一
MySQL数据库——基础篇总结(概述、SQL、函数、约束、多表查询、事务)一
24 5
|
1天前
|
SQL 数据库
SQL SUM() 函数
SQL SUM() 函数
7 0