DECLARE @RRANDOM BIGINT; DECLARE @UPPER BIGINT; DECLARE @LOWER BIGINT; ----This will create a random number SET @LOWER = 1 SET @UPPER = 9999999999999 SELECT @RRANDOM = ROUND(((@UPPER-@LOWER-1)*RAND()+@LOWER),0) SET @RANDOM = @RRANDOM
Idno Ticket_Number(Random Nos) ----------------------------------- 001 002 003
SELECT Idno, CONVERT(BIGINT, @LOWER+(@UPPER-@LOWER)*RAND()) As TicketNumber FROM YourTable
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)