Update all mnemonic codes and mnemonic codes

Source: Internet
Author: User

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

Related Article

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.