Terminology
ABS(CHECKSUM(NEWID())) % <n> ¶ Generate a random integer between 0 and <n>-1 inclusive.
CAST(CAST(0 AS BINARY) AS UNIQUEIDENTIFIER) ¶ Generate zero GUID in SQL Server.
CONVERT(DATETIME,FLOOR(CONVERT(NUMERIC(18,9),x))) ¶ Truncate DATETIME value to date without time.
CONVERT(VARCHAR(<width>),<variable>) ¶ Convert an integer into a string.
DATEADD(d, ABS(CHECKSUM(NEWID())) % DATEDIFF(d,<startDate>,<endDate>),<startDate>) ¶ Generate a random date within a range.
RAND ¶ Returns a pseudo-random float value from 0 through 1, exclusive.
RIGHT('000000000'+CONVERT(VARCHAR(9),ABS(CHECKSUM(NEWID())) % 1000000000),9) ¶ Generate a random unformatted Social Security Number (SSN).
ROW_NUMBER( ) OVER ( <partition_by_clause> <order_by_clause> ) ¶ Returns the sequential number of a row within a partition of a result set, starting at 1 for the first row in each partition.
Facts, Thoughts and Opinions
Images
- Subtopics
- Writings
Sources & Bookmarks
Name/Link | ¶ | Date |
---|---|---|
Calling a Web service from T-SQL | ¶ | 2015-07 |
Getting Started Testing Databases with tSQLt | ¶ | 2013-05-16 |
MERGE Statement Tips | ¶ | Pending |
Seven Sins against T-SQL Performance | ¶ |