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].