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
	@TableId1 int = OBJECT_ID('SoftadminApi.UserPhoto'),
	@TableName2 varchar(300) = 'UneditedPhotos'; -- Table does not have to exist.

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

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

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

Parameters

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

Id - A unique id used to identify the alias in the returned resultset.
ObjectId - ObjectId of a table that exists in the database.
ObjectName - Object name, without schema of a object that does not necessarily exists in the database.

Only one of ObjectId or ObjectName may be set for each array element, but may be mixed within the array.
@Blacklist optional nvarchar(max)
Comma separated list of aliases that will not be used.