|
-
Jul 10th, 2024, 07:55 AM
#1
Random card insertion
Hi.
This is for later this year but might as well be prepared.
We need to issue a couple of million of cards that would be random and the random part to be from a number and up.
So for example I have a card: 2100000199999 , the random cards would be something like 2100009199999 , 2140000199999,2103560199999 etc.
So it should be 21 as a starting point and over 2100000199999 .
Now I have this code that if I remember correctly was from JMC and I modified it so I can insert random cards.
Code:
DECLARE @startNumber bigint
DECLARE @endNumber bigint
set @startnumber = 2100000199990
set @endnumber = 2100000199999
DECLARE @i bigint
SET @i = @startNumber
DECLARE @card_carNumber nvarchar(50)
WHILE @i <= @endNumber
BEGIN
SET @card_carNumber = CONVERT(nvarchar(50), @i)
IF NOT EXISTS (SELECT * FROM cognetic_members_card WHERE card_cardNumber = CONVERT(nvarchar(50), @i))
INSERT into cognetic_members_card (card_cardNumber,card_status)
values (CONVERT(nvarchar(50), @i),5)
SET @i = @i + 1
END
That will work but as you can see I need a modification. I can probably do so but I have some concerns. I was thinking of a GUID but obviously I would have to cut it down. If I cut it down then I have to compare the inserted cards not to already exist and those cards are already millions, so I will probably block the server. Granted this will be a one off and maybe I can get away with it if I do it on late hours but still I don't think it's a good way.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|