Skip to content

Commit

Permalink
fix print and remove debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
tcakyavas committed Nov 18, 2024
1 parent 61149de commit 9fdb930
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
5 changes: 1 addition & 4 deletions sql/tSQLt_synapse/StoredProcedures/AssertEmptyTable.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ BEGIN
END
ELSE
BEGIN
PRINT 'EXECUTING AssertEmptyTable'
DECLARE @table_name_without_schema NVARCHAR(MAX) = OBJECT_NAME(OBJECT_ID(@table_name));
DECLARE @schema_name NVARCHAR(MAX) = OBJECT_NAME(OBJECT_ID(@table_name));
PRINT 'schema_name: ' + @schema_name
PRINT 'table_name_without_schema: ' + @table_name_without_schema
DECLARE @schema_name NVARCHAR(MAX) = OBJECT_SCHEMA_NAME(OBJECT_ID(@table_name));
EXEC [tSQLt_synapse].[Private_PrintTable] @schema_name, @table_name_without_schema;
END
DECLARE @message NVARCHAR(MAX);
Expand Down
2 changes: 0 additions & 2 deletions sql/tSQLt_synapse/StoredProcedures/Private_CompareTables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ BEGIN

IF @UnequalRowsExist > 0
BEGIN
PRINT 'EXECUTING CompareTables'
EXEC [tSQLt_synapse].[Private_PrintTable] @ResultTableSchema, @ResultTable;
PRINT 'Finished printing table'
SET @Cmd = 'DROP TABLE ' + @ResultTableWithSchema + ';'
EXEC [sp_executesql] @Cmd;
EXEC [tSQLt_synapse].[Fail] 'There exists unequal rows!';
Expand Down
11 changes: 5 additions & 6 deletions sql/tSQLt_synapse/StoredProcedures/Private_PrintTable.sql
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ BEGIN
SELECT
@ColumnList = STRING_AGG(
QUOTENAME([column_name])
+ SPACE(GREATEST([max_len], LEN(QUOTENAME([column_name]))) - LEN(QUOTENAME([column_name]))),
+ SPACE(GREATEST([max_len], LEN(QUOTENAME([column_name]))) - LEN(QUOTENAME([column_name])) + 1),
' '
) WITHIN GROUP (ORDER BY [column_id] ASC)
FROM #column_max_len;
Expand All @@ -81,12 +81,12 @@ BEGIN
'CAST(' + QUOTENAME([column_name])
+ ' AS NVARCHAR(MAX)) + SPACE(GREATEST('
+ CAST([max_len] AS NVARCHAR(MAX))
+ ',LEN('
+ ',LEN(QUOTENAME('''
+ [column_name]
+ ')) - LEN('
+ '''))) - LEN('
+ [column_name]
+ '))',
', '
','
) WITHIN GROUP (ORDER BY [column_id] ASC)
FROM #column_max_len;

Expand All @@ -96,13 +96,12 @@ BEGIN
DECLARE @Output NVARCHAR(MAX);
SELECT @Output = STRING_AGG(RowText, CHAR(10))
FROM (
SELECT CONCAT_WS('','', ' + @ColumnCastList + ') AS RowText
SELECT CONCAT_WS('', '', ' + @ColumnCastList + ') AS RowText
FROM [' + @SchemaName + '].[' + @TableName + ']
) t;
PRINT @Output;';

-- Execute the dynamic SQL
EXEC [sp_executesql] @Command;
PRINT @Command
END
END;

0 comments on commit 9fdb930

Please sign in to comment.