SQL Server database full-angle to half-Angle
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 go
Call:
Update Table1 set column1 = DBO. f_convert ( Column1 , 0 );
Transfer: http://blog.163.com/jiaqifeng_2008/blog/static/90518210201132811153445/