SQL Server NEWID in Snowflake, Databricks and BigQuery
Each target has a UUID generator under another name: UUID_STRING in Snowflake, uuid in Databricks and GENERATE_UUID in BigQuery. All return text, while SQL Server returns the uniqueidentifier type.
SQL Server function: NEWID() · SQL Server docs
Equivalents
| Target | Support | Syntax | Notes | Source |
|---|---|---|---|---|
| Snowflake | Different name | UUID_STRING() | Version 4 (random) UUID as a string; with two arguments it generates a version 5 UUID. | Snowflake docs |
| Databricks | Different name | uuid() | Returns a random UUID as a STRING. | Databricks docs |
| BigQuery | Different name | GENERATE_UUID() | Returns a random UUID as a STRING. | BigQuery docs |
Behavior differences to check
- ORDER BY NEWID() is a common way to shuffle rows. In the targets, order by RANDOM() (Snowflake), rand() (Databricks) or RAND() (BigQuery) instead of generating UUIDs.
- Columns typed uniqueidentifier become plain strings. Comparisons that relied on the SQL Server type (for example ordering by a uniqueidentifier) behave differently.
Examples
Add a random id to each row
SELECT NEWID() AS row_id, * FROM events;SELECT UUID_STRING() AS row_id, * FROM events;SELECT uuid() AS row_id, * FROM events;SELECT GENERATE_UUID() AS row_id, * FROM events;