Example and Notes
Use this SQL Server example as a starting point for development, troubleshooting, reporting, or maintenance work. Review it against your schema, data volume, permissions, and SQL Server version before using it in production.
This SQL Server/Azure script/function is very useful for generating a random X Digit number.
Declare @prmDigits Int
Set @prmDigits = 8
Select LEFT(SUBSTRING (RTRIM(RAND()) + SUBSTRING(RTRIM(RAND()),3,11), 3,11),@prmDigits) as RandomNumber
To learn more
about the WSI quoting
process.
Production Review
WSI can adapt this script for your database, improve error handling, tune performance, document the logic, and help deploy it safely.