You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Returns a cryptographic random number generated by the Crypto API (CAPI). The output is a hexadecimal number of the specified number of bytes.
31
+
This function returns a cryptographic, randomly-generated number, generated by the Crypto API (CAPI). `CRYPT_GEN_RANDOM` returns a hexadecimal number with a length of a specified number of bytes.
32
32
33
33
[Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
The lengthof the number being created. Maximum is 8000. *length*is type**int**.
43
+
The length, in bytes, of the number that `CRYPT_GEN_RANDOM` will create. The *length*argument has an **int** data type, and a value range between 1 and 8000. `CRYPT_GEN_RANDOM` returns NULL for an **int** value outside this range.
44
44
45
45
*seed*
46
-
Optional data to use as a random seed. There must be at least *length*bytes of data. *seed*is **varbinary(8000)**.
46
+
An optional hexadecimal number, for use as a random seed value. The length of *seed*must match the value of the *length*argument. The *seed*argument has a **varbinary(8000)** data type.
47
47
48
48
## Returned Types
49
49
**varbinary(8000)**
50
50
51
51
## Permissions
52
-
This function is public and does not require any special permissions.
52
+
This function is public and it does not require any special permissions.
53
53
54
54
## Examples
55
55
56
56
### A. Generating a random number
57
-
The following example generates a random number 50 bytes long.
57
+
This example generates a random number of length 50 bytes:
58
58
59
59
```sql
60
60
SELECT CRYPT_GEN_RANDOM(50) ;
61
61
```
62
62
63
-
The following example generates a random number 4 bytes long using a 4-byte seed.
63
+
This example generates a random number of length 4 bytes, using a 4-byte seed:
0 commit comments