Skip to content

Letters

Jonathan Bairstow edited this page Sep 8, 2020 · 1 revision

This collection of SQL artefacts can be used to randomly generate letter values, either singularly or in batches of up to 10000 values.

Reference data.

Bulk procedures described below generate values based on the values in [Reference].[Number]. This table can be populated by executing the procedure [Reference].[usp_Populate_Number].

Procedures and functions

[SingleValue].[ufn_Get_letter]

This function will return a random letter value. As a function; this method can be used to easily assign a value to an variable, or to update a field on a table.

Example usages:

Declare	@Letter char(1)

Select	@Letter = [SingleValue].[ufn_Get_letter]()

[SingleValue].[usp_Get_letter]

This procedure will return a random letter value. The generated value is returned via the output parameter @Letter, and so can be captured in a variable or passed back to a calling application.

Parameter Data Type Default Value Direction
@Letter char(1) None Output

Example usages:

Declare	@Letter char(1)
exec	[SingleValue].[usp_Get_Letter] @Letter out
Select	@Letter

[BulkValue].[usp_Get_letter]

This procedure will return up to 10000 random letter values. This procedure has the following input parameter:

Parameter Data Type Default Value
@QuantityRequired smallint None

A recordset with the following structure is returned:

Field Name Data Type
Letter char(1)

This method is useful for inserting bulk data directly in to a table, or as an ETL source.

Example Usage:

exec BulkValue.[usp_Get_Letter_Bulk] 1000

Clone this wiki locally