SoftadminGuide.Table_Aliases

Type: Table-valued function

When producing an SQL query with more than one table in the FROM-clause, you need to have table aliases. This function takes an array of tables and provides aliases according to our code standard.


-- Example: produces unique aliases for the tables SoftadminApi.UserPhoto and 'UneditedPhotos':
DECLARE
	@TableName1 varchar(300) = 'SoftadminApi.UserPhoto',
	@TableName2 varchar(300) = 'UneditedPhotos'; -- Table does not have to exist.

-- Json-string
DECLARE
	@Tables nvarchar(max) = CONCAT(
		'[{"Id":"table1","ObjectName":', @TableName1, '},
		{"Id":"table2","ObjectName":"', @TableName2, '"}]');

SELECT
	*
FROM
	SoftadminGuide.Table_Aliases(@Tables, NULL);

The @Tables parameter can be produced by the function SoftadminGuide.ParseField_Tables_AliasJson.

Parameters

@Tables mandatory nvarchar(max)
May use the Json returned by returned by SoftadminGuide.ParseField_Tables_AliasJson or a json array on the format:
[
{"Id":"table2","ObjectName":"NotAnActualTable"}
...
]

Id - A unique id used to identify the alias in the returned resultset.
ObjectName - Object name, without schema of an object that does not necessarily exists in the database.
@Blacklist optional nvarchar(max)
Comma separated list of aliases that will not be used.