drewsocia
2/1/2018 - 7:33 PM

search query

search query

declare @tcatid int 
DECLARE	@return_value int 
		
DECLARE @tsql varchar(max) 

select @tcatid = min( categoryid ) from mockupdata 
where categoryid >= 0  /* it broke here */ 

while @tcatid is not null 
begin 
-- DO A THING HERE @tcatid is THIS CAT ID!
/**/


		
SET @tsql = 'DELETE FROM mockupData'+cast(@tcatid as varchar(4))+' where mockupgroupID IN (1198304,1198372,1198388,1198441,1198458,5331838,103659903,103667551,103905094,103906852,104845282,104857112,104862475,104873094,1215847,1219900,1233727,1244398,1244415,104821478,104829118,105122727,105126249,105381369,106554663,2312323,100935499,103862708,103863563,103863865,106651967,106670269,106676791,106678394,106678800,106681456,1425967,105838049,106758593,106758913,106758929,106758952,106758978,106758994,106759012,106759027,106759043,106759062,106759077,106759091,106759098,106759112,106759128,106759146,106760251,106776160,106776192,106776263,106776290,106776318,106776348,106776374,106776402,106776440,106776466,106776483,1425928,106776505,106776531,106776555,106776579,106776601,106776629,106776655,106778542,106779760,3186,3913,9460,9461,104442189,105483635,106498611,106502412,106509568,106510046,107556939,107557799,1425746,1425781,1425824,104045359,104046388,104049500,104391603,104423446,104916836,105936318,105936887,106293093,106988167,107737511,107738441,350977,103977137,103996967,104523180,105192773,105529265,105859226,105865979,105868750,106230454,106825451,106826113,106827019,107306397,108409837,103836262,105032433,105355801,105440768,105444945,105534634,106901013,106901089,107687192,108056162,108067992,108070942,108077567,108466846,104003537,104354239,104355514,104356979,104362447,104759961,104786039,106698225,106704998,107239538,107239631,107538040,107538267,107543104,108395124,5463154,105986348,106956227,106958868,106959320,106960328,107348915,107353698,107709016,107709201,107729176,108172661,108173246,108603410,107191578,107195486,107195700,107204256,107573527,107585996,108344186,108362581,108363026,108363123,108370378,108654557,108654604,108654615,126559,103647618,103650823,104698187,105464222,106342168,107060824,107068279,107075964,107456205,107776429,107779224,107780692,108912065,170003,103248744,106018101,106018382,106441573,107100436,107918862,107921103,107922503,107925905,108204148,108204571,108567147,108956191,235755,104229874,104730493,105095442,106593258,106593259,106593543,107268214,108108075,108111086,108742466,109319422,109339527,110599324,106795020,107675552,108434235,108436554,108441330,108460289,108723365,108723389,110055630,110075215,111079224,111079308,111079404,111079492,108399614,108401549,108673047,108684241,108684672,109107360,110400721,110409576,111283524,111283619,111283710,111283786,111283878,111283965,111284054,111284120,111284202,1919145,105790381,106322936,108889119,109375944,110842946,114404799,118631355,123441285,123441424,123441561,123441705,123441835,5572259,97588285,104572917,104991380,105488661,105492322,106085391,106095304,107885559,107888299,108617750,110178715,124184805,124184882,104874287,105495651,106841758,106847741,106851595,106864731,106865582,107614929,107617785,107626504,107979554,107980793,125288686,125683585,108968718,109554052,110188488,111315688,113792237,116544835,122260438,146178144,146178233,146178594,146178758,146178861,146178917,146179059,146179331,107739110,107742338,109258741,121168806,121168836,121168841,121168866,121168902,121168910,126150537,130583842,135713363,146624008,125060744,135590394,135590404,112192320,114025482,114025750,114025830,114027722,114027812,119334090,130198874,111284282,111284361,111284427,111304152,120876733,120876970,120877297,131964555,146624203,146624275,146624347,146624423,146624542,146624613,146624695,146624840,108604773,108605488,109016809,113948944,121229239,130593553,6368333,106379736,107797647,107811292,108137798,108137820,108137827,108137996,108144136,111653368,111894865,124784549,131406138,127288671,108705897,109228239,109707886,109710697,113038942,113038967,113038972,113055633,113055770,113055890,113652290,124181111,124181209,124181593,108469240,109312670,111591055,112098579,114982944,115506808,116776470,116776473,117640533,133052801,109145544,109145670,109761057,109762065,110775675,111966148,116441642,145302449,126498589,131193675,145308121,146194033,146194480,146194676,146194777,146194973,146194987,146195195,146195294,146195473,146195476,146179333,146179334,146179335,146179336,146179337,146179338,146179339,110600795,113077379,120566844,120566851,120566865,121876777,107945797,108320040,108326380,124535246,131317377,115070832,115291103,115291542,115548264,115720079,115723752,124738218,124738306,135431982,135449245,135449862,135450225,151028449,107862564,108543943,109977488,110022433,112493559,113535283,123833068,124946906,124947046,124947195)'
BEGIN TRY 
EXECUTE (@tsql)
END TRY 
BEGIN CATCH 
	print ' no table' 
END CATCH 
print @tcatid 
select @tcatid = min( categoryid ) from mockupdata where categoryid > @tcatid 
end

/* modify base */ 
SET @tsql = 'DELETE from mockupData WHERE mockupgroupID IN (1198304,1198372,1198388,1198441,1198458,5331838,103659903,103667551,103905094,103906852,104845282,104857112,104862475,104873094,1215847,1219900,1233727,1244398,1244415,104821478,104829118,105122727,105126249,105381369,106554663,2312323,100935499,103862708,103863563,103863865,106651967,106670269,106676791,106678394,106678800,106681456,1425967,105838049,106758593,106758913,106758929,106758952,106758978,106758994,106759012,106759027,106759043,106759062,106759077,106759091,106759098,106759112,106759128,106759146,106760251,106776160,106776192,106776263,106776290,106776318,106776348,106776374,106776402,106776440,106776466,106776483,1425928,106776505,106776531,106776555,106776579,106776601,106776629,106776655,106778542,106779760,3186,3913,9460,9461,104442189,105483635,106498611,106502412,106509568,106510046,107556939,107557799,1425746,1425781,1425824,104045359,104046388,104049500,104391603,104423446,104916836,105936318,105936887,106293093,106988167,107737511,107738441,350977,103977137,103996967,104523180,105192773,105529265,105859226,105865979,105868750,106230454,106825451,106826113,106827019,107306397,108409837,103836262,105032433,105355801,105440768,105444945,105534634,106901013,106901089,107687192,108056162,108067992,108070942,108077567,108466846,104003537,104354239,104355514,104356979,104362447,104759961,104786039,106698225,106704998,107239538,107239631,107538040,107538267,107543104,108395124,5463154,105986348,106956227,106958868,106959320,106960328,107348915,107353698,107709016,107709201,107729176,108172661,108173246,108603410,107191578,107195486,107195700,107204256,107573527,107585996,108344186,108362581,108363026,108363123,108370378,108654557,108654604,108654615,126559,103647618,103650823,104698187,105464222,106342168,107060824,107068279,107075964,107456205,107776429,107779224,107780692,108912065,170003,103248744,106018101,106018382,106441573,107100436,107918862,107921103,107922503,107925905,108204148,108204571,108567147,108956191,235755,104229874,104730493,105095442,106593258,106593259,106593543,107268214,108108075,108111086,108742466,109319422,109339527,110599324,106795020,107675552,108434235,108436554,108441330,108460289,108723365,108723389,110055630,110075215,111079224,111079308,111079404,111079492,108399614,108401549,108673047,108684241,108684672,109107360,110400721,110409576,111283524,111283619,111283710,111283786,111283878,111283965,111284054,111284120,111284202,1919145,105790381,106322936,108889119,109375944,110842946,114404799,118631355,123441285,123441424,123441561,123441705,123441835,5572259,97588285,104572917,104991380,105488661,105492322,106085391,106095304,107885559,107888299,108617750,110178715,124184805,124184882,104874287,105495651,106841758,106847741,106851595,106864731,106865582,107614929,107617785,107626504,107979554,107980793,125288686,125683585,108968718,109554052,110188488,111315688,113792237,116544835,122260438,146178144,146178233,146178594,146178758,146178861,146178917,146179059,146179331,107739110,107742338,109258741,121168806,121168836,121168841,121168866,121168902,121168910,126150537,130583842,135713363,146624008,125060744,135590394,135590404,112192320,114025482,114025750,114025830,114027722,114027812,119334090,130198874,111284282,111284361,111284427,111304152,120876733,120876970,120877297,131964555,146624203,146624275,146624347,146624423,146624542,146624613,146624695,146624840,108604773,108605488,109016809,113948944,121229239,130593553,6368333,106379736,107797647,107811292,108137798,108137820,108137827,108137996,108144136,111653368,111894865,124784549,131406138,127288671,108705897,109228239,109707886,109710697,113038942,113038967,113038972,113055633,113055770,113055890,113652290,124181111,124181209,124181593,108469240,109312670,111591055,112098579,114982944,115506808,116776470,116776473,117640533,133052801,109145544,109145670,109761057,109762065,110775675,111966148,116441642,145302449,126498589,131193675,145308121,146194033,146194480,146194676,146194777,146194973,146194987,146195195,146195294,146195473,146195476,146179333,146179334,146179335,146179336,146179337,146179338,146179339,110600795,113077379,120566844,120566851,120566865,121876777,107945797,108320040,108326380,124535246,131317377,115070832,115291103,115291542,115548264,115720079,115723752,124738218,124738306,135431982,135449245,135449862,135450225,151028449,107862564,108543943,109977488,110022433,112493559,113535283,123833068,124946906,124947046,124947195)' 

EXECUTE (@tsql)