且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何创建一个随机函数,它将随机地从表中记录一行

更新时间:2023-11-23 21:33:10

试试看,

Hi try this,

Select * from tablename order by newid()


这将随机检索行...


this will retrieve the rows randomnly...


要选择随机记录,请结合TOP和NEWID:
To select a random record, combine TOP with NEWID:
SELECT TOP 1 * from MyTable ORDER BY NEWID()

您可能需要用过程输出替换MyTable.

In your case, you will probably need to replace MyTable with your procedure output.