From 1994a764dde2887f3364a5286827c2556eac69ab Mon Sep 17 00:00:00 2001 From: Sait ORHAN Date: Wed, 7 Dec 2022 23:35:55 +0300 Subject: [PATCH 1/3] Querying Random Data Using the NEWID() Function Added random data query example using NEWID function. --- docs/t-sql/functions/newid-transact-sql.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/t-sql/functions/newid-transact-sql.md b/docs/t-sql/functions/newid-transact-sql.md index 5ae7387c903..15559aff873 100644 --- a/docs/t-sql/functions/newid-transact-sql.md +++ b/docs/t-sql/functions/newid-transact-sql.md @@ -114,6 +114,18 @@ SET @myid = 'A972C577-DFB0-064E-1189-0154C99310DAAC12'; SELECT @myid; GO ``` + + +### D. Querying Random Data Using the NEWID() Function + With the following example, we are querying a random record from the `Production.Product` table using the `NEWID()` function. We can increase the `TOP` value to query more random records. + +```sql +SELECT TOP 1 ProductID, Name, ProductNumber +FROM Production.Product +ORDER BY NEWID() +GO +``` + ## See Also [NEWSEQUENTIALID (Transact-SQL)](../../t-sql/functions/newsequentialid-transact-sql.md) From d8cf75b4baaa74b484c0d6b76d34c2b4f3dd7844 Mon Sep 17 00:00:00 2001 From: Mike Ray <15928587+MikeRayMSFT@users.noreply.github.com> Date: Tue, 13 Dec 2022 09:34:48 -0800 Subject: [PATCH 2/3] Edited submission --- docs/t-sql/functions/newid-transact-sql.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/t-sql/functions/newid-transact-sql.md b/docs/t-sql/functions/newid-transact-sql.md index 15559aff873..e057330a6d7 100644 --- a/docs/t-sql/functions/newid-transact-sql.md +++ b/docs/t-sql/functions/newid-transact-sql.md @@ -114,10 +114,10 @@ SET @myid = 'A972C577-DFB0-064E-1189-0154C99310DAAC12'; SELECT @myid; GO ``` + +### D. Query random data with the NEWID() Function - -### D. Querying Random Data Using the NEWID() Function - With the following example, we are querying a random record from the `Production.Product` table using the `NEWID()` function. We can increase the `TOP` value to query more random records. +The following example queries a random record from the `Production.Product` table using the `NEWID()` function. To query more records radomly, increase the `TOP` value. ```sql SELECT TOP 1 ProductID, Name, ProductNumber From a19299e533651b5ec691c813c575f492d5da4532 Mon Sep 17 00:00:00 2001 From: Jeff Borsecnik <36546697+jborsecnik@users.noreply.github.com> Date: Tue, 13 Dec 2022 14:27:24 -0800 Subject: [PATCH 3/3] Update newid-transact-sql.md --- docs/t-sql/functions/newid-transact-sql.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/t-sql/functions/newid-transact-sql.md b/docs/t-sql/functions/newid-transact-sql.md index e057330a6d7..217c8e3807f 100644 --- a/docs/t-sql/functions/newid-transact-sql.md +++ b/docs/t-sql/functions/newid-transact-sql.md @@ -115,7 +115,7 @@ SELECT @myid; GO ``` -### D. Query random data with the NEWID() Function +### D. Query random data with the NEWID() function The following example queries a random record from the `Production.Product` table using the `NEWID()` function. To query more records radomly, increase the `TOP` value.