The two required functions:
Use [Oaerp]
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 au when @chn then char (@n) Else @c end
From
Select Top * FROM (
Select CHN =
' Acridine ' UNION ALL Select
' Eight ' union ALL select
' Cha ' union ALL Select
' Otah ' UNION ALL Select
' Ehegan ' UNION ALL Select
' FA ' UNION ALL Select
' Xu ' union ALL Select
' Hafnium ' UNION ALL Select
' Not ' union ALL select--because has no ' i '
' Not ' UNION ALL Select
' Ka ' UNION ALL Select
' Garbage ' UNION ALL Select
' 嘸 ' UNION ALL Select
' Hallasan ' UNION ALL Select
' Oh ' UNION ALL Select
' 妑 ' UNION ALL Select
' Seven ' union ALL Select
' 呥 ' UNION ALL Select
' SA ' UNION ALL Select
' He ' UNION ALL Select
' 屲 ' UNION ALL select--no ' u '
' 屲 ' UNION ALL select--no ' V '
' 屲 ' UNION ALL Select
' XI ' UNION ALL Select
' Ya ' UNION ALL Select
' As ' union ALL select @chn) as a
ORDER BY CHN COLLATE Chinese_prc_ci_as
) as B
Return (@c)
End
Use [Oaerp]
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, @e varchar, @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 @[email protected] +@e
ELSE
IF @iAscii >=176 and @iAscii <=247
SELECT @[email protected] + dbo.f_ch2py (@e)
ELSE SELECT @[email protected]
SELECT @[email protected]+1, @[email protected]+1 END
RETURN @cHelpCode
END
To execute an UPDATE statement:
Update ggoods SET abc = (SELECT dbo. F_gethelpcode (name))
--name is the product name
All updates to the mnemonic code