use database;
DECLARE @sql NVARCHAR(MAX) ;
select @sql = 'alter table ' + t.TABLE_NAME + ' REBUILD WITH (DATA_COMPRESSION=ROW)'
FROM INFORMATION_SCHEMA.TABLES t
PRINT @sql;
EXEC sp_executesql @sql
use database;
DECLARE @sql NVARCHAR(MAX) ;
set @sql=''
select @sql = @sql+';'+ 'alter table ' + t.TABLE_NAME + ' REBUILD WITH (DATA_COMPRESSION=ROW)'
FROM INFORMATION_SCHEMA.TABLES t
PRINT @sql;
EXEC sp_executesql @sql