Free BarCode128 SQL±àÂë
CREATE FUNCTION StringToBarcode
(@Value Varchar(50) )
RETURNS NVarchar(100)
AS
BEGIN
Declare @charCount int
Declare @charPos int, @minCharPos int
declare @currentChar int, @checksum int
Declare @isTableB int,@isValid int
Declare @returnValue NVarchar(100)
set @isTableB=1
set @isValid=1
set @returnValue=''
if Len(@Value)>0
BEGIN
set @charCount=1
while @charCount<=Len(@Value)
BEGIN
SET @currentChar = ASCII(Substring(@value,@charCount, 1))
IF NOT (@currentChar>=32 AND @currentChar<=126)
BEGIN
SET @isValid=0
break
END
SET @charCount=@charCount+1
END
if @isValid=1
BEGIN
SET @charPos=1
WHILE @charPos<=LEN(@value)
BEGIN
if @isTableB=1
BEGIN
--See if interesting to switch to table C
--yes for 4 digits at start or end, else if 6 digits
IF @charPos=1 or @charPos+3=Len(@Value)
SET @minCharPos=4
ELSE
SET @minCharPos=6
SET @minCharPos=dbo.IsNumber(@Value,@charPos, @minCharPos)
if @minCharPos<0
BEGIN
--Choice table C
IF @charPos=1
--Starting with table C
SET @returnValue=Nchar(205)
&nbs
Ïà¹ØÎĵµ£º
CASE ¿ÉÄÜÊÇ SQL Öб»ÎóÓÃ×î¶àµÄ¹Ø¼ü×ÖÖ®Ò»¡£ËäÈ»Äã¿ÉÄÜÒÔÇ°ÓùýÕâ¸ö¹Ø¼ü×ÖÀ´´´½¨×ֶΣ¬µ«ÊÇËü»¹¾ßÓиü¶àÓ÷¨¡£ÀýÈ磬Äã¿ÉÒÔÔÚ WHERE
×Ó¾äÖÐʹÓà CASE¡£
Ê×ÏÈÈÃÎÒÃÇ¿´Ò»Ï CASE µÄÓï·¨¡£ÔÚÒ»°ãµÄ SELECT ÖУ¬ÆäÓï·¨ÈçÏ£º
SELECT =
CASE
WHEN THEN
WHEN THEN
ELSE
......
Ò»¡¢×Ö·ûת»»º¯Êý
1¡¢ASCII()
·µ»Ø×Ö·û±í´ïʽ×î×ó¶Ë×Ö·ûµÄASCII ÂëÖµ¡£ÔÚASCII£¨£©º¯ÊýÖУ¬´¿Êý×ÖµÄ×Ö·û´®¿É²»ÓÑ’À¨ÆðÀ´£¬µ«º¬ÆäËü×Ö·ûµÄ×Ö·û´®±ØÐëÓÑ’À¨ÆðÀ´Ê¹Ó㬷ñÔò»á³ö´í¡£
2¡¢CHAR()
½«ASCII Âëת»»Îª×Ö·û¡£Èç¹ûûÓÐÊäÈë0 ~ 255 Ö®¼äµÄASCII ÂëÖµ£¬CHAR£¨£© ·µ»ØNULL ¡£
3¡¢LOWE ......
ÔÎĵØÖ·£ºhttp://www.dingos.cn/index.php?topic=1688.0
OracleÓÐrownumÓÃÓÚ·ÃÎʱíÖÐÐкš£ÄÇôÔÚSQL ServerÖÐÊÇ·ñÓеÈЧµÄÄØ£¿»òÕßÔÚSQL ServerÖÐÈçºÎÊä³öÐкţ¿
-----------------------------------
ÔÚSQL ServerÖÐûÓÐÖ±½ÓµÈЧÓÚOracleµÄrownum
-----------------------------------
Ñϸñ˵À´£¬ÔÚ¹ØϵÊý¾Ý¿âÖУ¬± ......