帮助生成随机数 [英] Help on generating random numbers

查看:143
本文介绍了帮助生成随机数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试生成一个随机数以用作sql数据库中的唯一标识符时,我需要帮助.我在Web应用程序上有一个文本框,假设用户应输入用户名.我希望计算机生成一个唯一的数字,该数字采用在这种情况下在文本框中输入的名称的前两个字符(mi),并将其与当前日期和时间连接为一个长字符串.例如,如果日期是10/20/2012,时间是10:56 pm,我希望唯一的号码是Mi102020121056.Mi来自文本框中输入的字符串,这是micheal.请帮帮我,我将不胜感激

Please i need help on trying to generate a random number to use as a unique identifier in sql database.I have a text box on a web application that a user is suppose to enter a username.Lets say a user enters his name as Micheal in this textbox.I want the computer to generate a unique number taking the the first two characters of the name entered in the textbox in this case which is (mi) and concatenate it with the current date and time as one long string.For example if the date is 10/20/2012 and time is 10:56pm i want the unique number to be Mi102020121056.The Mi iscoming from the string entered in the textbox which is micheal.Please help me out i will be very grateful for any help given.

推荐答案

您可以根据从Select NewID()中检索到的结果来修改代码. 它将提供唯一ID

有关NewID()的更多信息 [
You can modify your code as per result retrieve from Select NewID()
It will give Unique ID

More About NewID()[^]


这篇关于帮助生成随机数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆