Update the string of the string list, the specified location string

zhaozj2021-02-16  73

if EXISTS (Select * from dbo.sysObjects where id = Object_id (n '[dbo]. [f_updatestr]') and xtype in (N'FN ', N'IF', N'TF ') DROP FUNCTION [DBO] [f_updatestr] Go

/ * - Update a string of the specified location in the list of strings

In the update string list, the string of the specified location is a new value if the location is out of the range, does not make an update.

- Zou Jian 2004.07 (Please keep this information) - * /

/ * - Call example

Select dbo.f_updatestr ('001 | 002 | 003 |', 1, '00a', '|') - * / CREATE FUNCTION F_UPDATESTR (@s var, @ newstr varchar (100), @SPListStr VARCHAR (10) - Separator of the string list) Returns varchar (8000) asbegin declare @i int, @ i tent

Select @ i = charIndex (@ spliststr, @ spliststr @ s), @ i = len (@splistStr) while @i> 0 and @POS> 1 select @ = charindex (@ spliststr, @ s, @ i) @ Ilen, @ POS = @ POS-1 Return (Case @i when 0 Then @S else stuff (@ s, @ i, charindex (@ spliststr, @ s @ spliststr, @ i) - @ i, @ Newstr) end) Endgo

转载请注明原文地址:https://www.9cbs.com/read-12273.html

New Post(0)