Skip to content

Instantly share code, notes, and snippets.

@Tgo1014
Created April 4, 2017 14:38
Show Gist options
  • Save Tgo1014/c84a070a609eea58d0b00df3fc4d016b to your computer and use it in GitHub Desktop.
Save Tgo1014/c84a070a609eea58d0b00df3fc4d016b to your computer and use it in GitHub Desktop.
Useful when updating a large quantities of rows from a big table
WHILE 1 = 1
BEGIN
UPDATE TOP(100000) A
SET CIA = CASE
WHEN DS_INDICADOR = 'AUTO' THEN LEFT(RIGHT(CD_ITEM,14),3)
WHEN DS_INDICADOR IN ('RE','RAMOS ELEMENTARES') THEN LEFT(RIGHT(CD_ITEM,10),3)
ELSE 0
END
FROM DB_PGC_PRODUCAO..TB_DM_INFO_GER_ANALITICO_HIST A
WHERE CIA IS NULL
IF @@ROWCOUNT < 1 BREAK;
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment