SQL implementation random extract data

xiaoxiao2021-03-06  64

The Northwind database comes with SQL Server 2000 as an example: SELECT TOP 3 * from EmployeesOrder by newid () multiple times, see the output of the output? If you want the data that is called every time you call it, this is a tag each time you call a tag, such as: add a flag field Flag (Tinyint) to the Employee table, so that it defaults to 1 and, Update Employees Set Flag = 1, before calling, all FLAG is equal to 1 After the call Update Employees set flag = 0 Where EmployeeiD = ... Called code changed to SELECT TOP 3 * from Employeeswhere Flag = 1Order by newid ( )

转载请注明原文地址:https://www.9cbs.com/read-119520.html

New Post(0)