Update all mnemonic codes and mnemonic codes
Two functions are required:
USE [oa erp]
GO
/***** Object: UserDefinedFunction [dbo]. [f_ch2py] Script Date: 12/31/2014 17:12:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER function [dbo]. [f_ch2py] (@ chn nchar (1 ))
Returns char (1)
As
Begin
Declare @ n int
Declare @ c char (1)
Set @ n = 63
Select @ n = @ n + 1,
@ C = case chn when @ chn then char (@ n) else @ c end
From (
Select top 27 * from (
Select chn =
'Ay' union all select
'8' union all select
'Signature' union all select
'Signature' union all select
'Signature' union all select
'Output' union all select
'Signature' union all select
'Hagh' union all select
'Open 'Union all select -- because have no 'I'
'Open 'union all select
'Signature' union all select
'Signature' union all select
'Signature' union all select
'Signature' union all select
'Ou' union all select
'Signature' union all select
'7' union all select
'Signature' union all select
'Signature' union all select
'Others' union all select
'Ignore' union all select -- no 'U'
'Hangzhou' union all select -- no 'V'
'Signature' union all select
'Xi 'union all select
'Ya 'union all select
'Signature' union all select @ chn) as
Order by chn COLLATE Chinese_PRC_CI_AS
) As B
Return (@ c)
End
USE [oa erp]
GO
/***** Object: UserDefinedFunction [dbo]. [F_GetHelpCode] Script Date: 12/31/2014 17:12:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Alter function [dbo]. [F_GetHelpCode] (
@ CName VARCHAR (20 ))
Returns varchar (12)
AS
BEGIN
DECLARE @ I SMALLINT, @ L SMALLINT, @ cHelpCode VARCHAR (12), @ e VARCHAR (12), @ iAscii SMALLINT
SELECT @ I = 1, @ L = 0, @ cHelpCode =''
While @ L <= 12 AND @ I <= LEN (@ cName) BEGIN
SELECT @ e = LOWER (SUBSTRING (@ cname, @ I, 1 ))
SELECT @ iAscii = ASCII (@ e)
IF @ iAscii> = 48 AND @ iAscii <= 57 OR @ iAscii> = 97 AND @ iAscii <= 122 or @ iAscii = 95
SELECT @ cHelpCode = @ cHelpCode + @ e
ELSE
IF @ iAscii & gt; = 176 AND @ iAscii <= 247
SELECT @ cHelpCode = @ cHelpCode + dbo. f_ch2py (@ e)
Else select @ L = @ L-1
SELECT @ I = @ I + 1, @ L = @ L + 1 END
RETURN @ cHelpCode
END
Execute the update statement:
Update ggoods set abc = (select dbo. F_GetHelpCode (name ))
-- Name is the product name