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.