SQL Server database full-angle and half-angle Conversion Method

Source: Internet
Author: User
CREATEFUNCTIONf_Convert (@ strNVARCHAR (4000), -- string to be converted @ flagbit -- Conversion flag, 0 to halfwidth, 1 to fullwidth) RETURNSnvarchar (4000) ASBEGINDECLARE @ patnvarchar (8 ), @ stepint, @ iint, @ spcintIF @ flag0SELECT @ patN, @ step-

Create function f_Convert (@ str NVARCHAR (4000), -- string to be converted @ flag bit -- Conversion flag, 0 to halfwidth, 1 to fullwidth) 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), -- string to be converted @ flag bit -- Conversion flag, 0 to halfwidth, 1 to fullwidth) 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 is the table to be converted. The U.S. server, the Hong Kong Vm, and column1 are the table fields to be converted.
Call: update table1 set column1 = dbo. f_Convert (column1, 0);, Hong Kong VM

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.