/****** SQL Convert full-width/half-width functions start ******/create function Convertwordangle (@str NVARCHAR (4000),--the string to be converted @flag bit--conversion flag, 0 converted to half angle, 1 Convert to perfect corner) 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)) [email protected]), @i=patindex (@pat COLLATE Latin1_General_BIN, @str) RETURN (@str) End/****** SQL Convert full-width/half-width function ends ******/--Call Example: Update news set title=dbo. Convertwordangle (title,0);
SQL Full-width half-width conversion-(excerpt)