Advertisement
Guest User

Untitled

a guest
Apr 18th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.42 KB | None | 0 0
  1. DECLARE @i TINYINT = 2
  2.     , @param NVARCHAR(32) = N'@int TINYINT'
  3.     , @sql NVARCHAR(MAX) = '
  4.         UPDATE dwh.sap.AccountingDocumentSegment
  5.         SET ExtraBudgetaryHolderId = 0
  6.         WHERE ExtraBudgetaryHolderId IS NULL
  7.             AND $partition.fn_partition_year(FiscalYear) = @int;
  8.         '
  9. WHILE 1 = 1
  10. BEGIN
  11.     BEGIN TRY
  12.         EXECUTE sp_executesql @sql, @param, @int = @i;
  13.         SET @i += 1;
  14.     END TRY
  15.     BEGIN CATCH
  16.         THROW
  17.         RETURN;
  18.     END CATCH
  19. END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement