Home > Database > Mysql Tutorial > SqlServer数据库全角和半角互转的方法

SqlServer数据库全角和半角互转的方法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:43:50
Original
1235 people have browsed it

CREATE FUNCTION f_Convert( @str NVARCHAR( 4000 ), -- 要转换的字符串 @flag bit -- 转换标志,0转换成半角,1转换成全角 )RETURNS nvarchar( 4000 ) AS BEGIN DECLARE @pat nvarchar( 8 ),@step int ,@i int ,@spc int IF @flag = 0 SELECT @pat =N,@step=-

CREATE FUNCTION f_Convert( @str NVARCHAR(4000), --要转换的字符串 @flag bit --转换标志,0转换成半角,1转换成全角 )RETURNS nvarchar(4000) AS BEGIN DECLARE @pat nvarchar(8),@step int,@i int,@spc int IF @flag=0 SELECT @pat=N,@step=-65248, @str=REPLACE(@str,N'  ',N' ') ELSE SELECT @pat=N,@step=65248, @str=REPLACE(@str,N' ',N'  ') SET @i=PATINDEX(@pat COLLATE LATIN1_GENERAL_BIN,@str) WHILE @i> 0 SELECT @str=REPLACE(@str, SUBSTRING(@str,@i,1), NCHAR(UNICODE(SUBSTRING(@str,@i,1))+@step)) ,@i=PATINDEX(@pat COLLATE LATIN1_GENERAL_BIN,@str) RETURN(@str) END --table1为要转换的表,美国服务器,香港虚拟主机,column1为要转换的表字段
调用:update table1
set column1=dbo.f_Convert(column1,0); ,香港虚拟主机

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Problem with tp6 connecting to sqlserver database
From 1970-01-01 08:00:00
0
0
0
Unable to connect to SQL Server in Laravel
From 1970-01-01 08:00:00
0
0
0
Methods of parsing MYD, MYI, and FRM files
From 1970-01-01 08:00:00
0
0
0
SQLSTATE: User login failed
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template