Skip to content

Commit

Permalink
fix nullability bug with RenameCommands
Browse files Browse the repository at this point in the history
  • Loading branch information
EitanBlumin committed May 15, 2024
1 parent 643aa1e commit 4093e9c
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ DECLARE
PARAMETERS
********************** !!! DO NOT EDIT ANYTHING ABOVE THIS LINE !!! ************************/

@SourceTableName SYSNAME = 'dbo.OnlineIndexTest'
@SourceTableName SYSNAME = 'dbo.SourceTableToRebuild'
,@ChunkIntervalForSingleColumnPK INT = 1000
,@OperationDeltaColumn SYSNAME = '___Operation' -- must be different from any existing table columns
,@PrecedenceDeltaColumn SYSNAME = '___Precedence' -- must be different from any existing table columns
Expand Down Expand Up @@ -417,7 +417,7 @@ SET @CMD = N'
SELECT @CMD = @CMD + N'
ALTER TABLE ' + @NewTableName + N' ADD CONSTRAINT ' + QUOTENAME(pk.name + @NewTableNamePostfix) COLLATE database_default
,
@RenameCommands = @RenameCommands + N'
@RenameCommands = ISNULL(@RenameCommands, N'') + N'
EXEC sp_rename N''' + pk.name COLLATE database_default + @NewTableNamePostfix + N''', N''' + pk.name COLLATE database_default + N''';'

FROM sys.indexes AS pk
Expand All @@ -434,7 +434,7 @@ EXEC sp_rename N''' + pk.name COLLATE database_default + @NewTableNamePostfix +
ALTER TABLE ' + @NewTableName + N' ADD CONSTRAINT ' + QUOTENAME(df.name + @NewTableNamePostfix) COLLATE database_default + N' DEFAULT ' + df.definition COLLATE database_default + N' FOR ' + QUOTENAME(c.name) COLLATE database_default + N';'
,
@RenameCommands = @RenameCommands + N'
@RenameCommands = ISNULL(@RenameCommands, N'') + N'
EXEC sp_rename N''' + df.name COLLATE database_default + @NewTableNamePostfix + N''', N''' + df.name COLLATE database_default + N''';'
FROM sys.default_constraints AS df
INNER JOIN sys.columns AS c
Expand Down Expand Up @@ -1132,7 +1132,7 @@ RAISERROR(N''Done. You can now drop the tables ' + @DeltaTableName + N' and ' +
DROP TABLE ' + @DeltaTableName + N';
DROP TABLE ' + @OldTableName + N';
GO
' + @RenameCommands + N'
' + ISNULL(@RenameCommands, N'') + N'
*/
GO
'
Expand Down

0 comments on commit 4093e9c

Please sign in to comment.