Answers for "generate test card numbers"
https://ask.sqlservercentral.com/questions/101899/generate-test-card-numbers.html
The latest answers for the question "generate test card numbers"Answer by cybarcom
https://ask.sqlservercentral.com/answers/101999/view.html
SQL Server has a built-in function to generate random number. The function is RAND(). It is a mathematical function. It returns a random float value between 0 and 1. We can also use an optional seed parameter, which is an integer expression (tinyint, smallint or int) that gives the seed or start value.To use it, we need to use a simple SELECT statement as follows:
SELECT RAND() AS [RandomNumber]
For more example please click :[URL][1]
Thanks
[1]: http://cybarlab.blogspot.com/2013/02/random-number-in-sql.htmlTue, 30 Apr 2013 05:31:30 GMTcybarcomAnswer by Fatherjack
https://ask.sqlservercentral.com/answers/101901/view.html
It depends quite how random and how unique you want them...
Select ABS(CHECKSUM(NEWID())) % <INT>
will give you a random number up to the value of `INT`
Note however, its not guaranteed to be unique or truly random.
If you need a hand prefixing it with a 1 come back again.
[edit - full solution]
DECLARE @var bigint
SELECT @var = 100000000000000 +
(CAST(ABS(CHECKSUM(NEWID())) % 10000000 AS bigint)
* CAST(ABS(CHECKSUM(NEWID())) % 10000000 AS bigint))
PRINT @var
print LEN(@var)
GO 20
should always give a 15 digit number starting with a 1Fri, 26 Apr 2013 14:22:21 GMTFatherjack