In SQL-Server we have NEWID() function which will give us a new id every time we can see this by executing the below statement.
SELECT NEWID()
We can use this function in our order by clause while using the TOP Predicate.
Example :
SELECT TOP(3)
EmployeeName,
Salary
FROM
Employee
ORDER BY
NEWID()
This statement will give us every time different TOP 3 records.
Thx,
RS
SELECT NEWID()
We can use this function in our order by clause while using the TOP Predicate.
Example :
SELECT TOP(3)
EmployeeName,
Salary
FROM
Employee
ORDER BY
NEWID()
This statement will give us every time different TOP 3 records.
Thx,
RS
No comments:
Post a Comment