Skip to content

Commit

Permalink
create table before select
Browse files Browse the repository at this point in the history
  • Loading branch information
yarenylmz committed Dec 18, 2024
1 parent 4bcfdcd commit d734908
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sql/tSQLt_synapse/StoredProcedures/Private_PrintTable.sql
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,19 @@ BEGIN

IF OBJECT_ID ('tempdb..#PrintTable') IS NOT NULL
DROP TABLE #PrintTable;

CREATE TABLE [#PrintTable]
(
[RowText] [nvarchar](MAX) NOT NULL,
[sequence] [int] NOT NULL
)
WITH (DISTRIBUTION = ROUND_ROBIN, CLUSTERED INDEX ([sequence]));

PRINT ('After truncate');

SET @Command = N'
INSERT INTO #PrintTable
SELECT RowText, ROW_NUMBER() OVER(ORDER BY RowText) AS sequence
INTO #PrintTable
FROM (
SELECT CONCAT_WS('', '', ' + @ColumnCastList + ') AS RowText
FROM [' + @SchemaName + '].[' + @TableName + ']
Expand Down

0 comments on commit d734908

Please sign in to comment.