Merhaba ;
Barkod oluşturmak için SQL ile komut bilgilerini paylaşmak istedim..
DECLARE @SAYAC INT = 1;
WHILE @SAYAC < 1000
BEGIN
DECLARE @RND NVARCHAR(13) = ( SELECT RIGHT(CAST(CAST(NEWID() AS VARBINARY(36)) AS BIGINT),
12)
);
SET @RND = DBO.FN_TEST(@RND);
PRINT @RND;
/* Tabloya direk insert yapmak için */
–INSERT INTO dbo.TBLBAECODE
— ( BARCODE )
–VALUES ( @RND — BARCODE – nvarchar(13)
— );
SET @SAYAC += 1;
END;
Doğrulama Fonksiyonu [Alıntıdır]
CREATE FUNCTION [DBO].[FN_KONTROLEAN] ( @INPUTUPC NCHAR(20) )
RETURNS NCHAR(13)
BEGIN
DECLARE @SUM INT;
DECLARE @CHKDGT NCHAR(1);
IF ( ( LEN(@InputUPC) < 12 )
OR ( LEN(@InputUPC) > 13 )
)
BEGIN
RETURN NULL;
END;
ELSE
IF ( LEN(@InputUPC) = 13 )
BEGIN
SET @InputUPC = LEFT(@InputUPC, 12);
END;
SET @Sum = 3 * ( CAST(SUBSTRING(@InputUPC, 2, 1) AS INT)
+ CAST(SUBSTRING(@InputUPC, 4, 1) AS INT)
+ CAST(SUBSTRING(@InputUPC, 6, 1) AS INT)
+ CAST(SUBSTRING(@InputUPC, 8, 1) AS INT)
+ CAST(SUBSTRING(@InputUPC, 10, 1) AS INT)
+ CAST(SUBSTRING(@InputUPC, 12, 1) AS INT) )
+ CAST(SUBSTRING(@InputUPC, 1, 1) AS INT)
+ CAST(SUBSTRING(@InputUPC, 3, 1) AS INT)
+ CAST(SUBSTRING(@InputUPC, 5, 1) AS INT)
+ CAST(SUBSTRING(@InputUPC, 7, 1) AS INT)
+ CAST(SUBSTRING(@InputUPC, 9, 1) AS INT)
+ CAST(SUBSTRING(@InputUPC, 11, 1) AS INT);
IF ( @Sum % 10 ) = 0
BEGIN
SET @ChkDgt = ‘0’;
END;
ELSE
IF ( @Sum % 10 ) = 1
BEGIN
SET @ChkDgt = ‘9’;
END;
ELSE
IF ( @Sum % 10 ) = 2
BEGIN
SET @ChkDgt = ‘8’;
END;
ELSE
IF ( @Sum % 10 ) = 3
BEGIN
SET @ChkDgt = ‘7’;
END;
ELSE
IF ( @Sum % 10 ) = 4
BEGIN
SET @ChkDgt = ‘6’;
END;
ELSE
IF ( @Sum % 10 ) = 5
BEGIN
SET @ChkDgt = ‘5’;
END;
ELSE
IF ( @Sum % 10 ) = 6
BEGIN
SET @ChkDgt = ‘4’;
END;
ELSE
IF ( @Sum % 10 ) = 7
BEGIN
SET @ChkDgt = ‘3’;
END;
ELSE
IF ( @Sum % 10 ) = 8
BEGIN
SET @ChkDgt = ‘2’;
END;
ELSE
IF ( @Sum % 10 ) = 9
BEGIN
SET @ChkDgt = ‘1’;
END;
ELSE
BEGIN
SET @ChkDgt = ‘Z’;
END;
RETURN LEFT(@InputUPC,12) + @ChkDgt;
END;
Faydalı Olması Dileğiyle