declare @trun_name varchar(50) declare name_cursor cursor for select 'truncate table ' name from sysobjects where xtype='U' and status > 0 and name not like 'Temp_' and name not like 'HM_EM_OutOfPositionCommunicationR' open name_cursor fetch next from name_cursor into @trun_name while @@FETCH_STATUS = 0 begin print @trun_name '' exec (@trun_name '') fetch next from name_cursor into @trun_name end close name_cursor deallocate name_cursor