如何在SQL中的字符串中将字符添加到指定位置?

时间:2017-11-29 09:53:42

标签: sql string sql-server-2012

我有一个最多可包含500个字符的列( 消息Varchar(500) )。

我需要在250位插入Caret( ^ ),或者如果少于250个字符,即120,则在最后一个字符位置插入。

示例497个字符;

strong textFar far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows b^y their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth. Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographi.

Caret插入字符250,将“by”分成“b ^ y”。

示例140个字符;

Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in.^

由于此示例的字符少于250个,因此在消息的末尾插入了插入符号。

将输入的最大字符数为499,因此插入Caret会留下1个字符。

任何帮助都会感激不尽。

0 个答案:

没有答案