how to assign results from exec to variable
<p>How do I assign the results of an exec command to a variable. like the below, so when I do select @sql2 I get the result of the executed varchar sql.</p>

<pre><code>declare @sql varchar(500)
declare @sql2 varchar(max)
set @sql = 'SELECT 
                PDB.OutletBrandID, OB.BrandName
            FROM 
                ProductDistributionBrand PDB
            INNER JOIN 
                [IND_roadchef].dbo.OutletBrands OB 
            ON 
                PDB.OutletBrandID = OB.OutletBrandID

            FOR XML PATH(''ProductDistributionBrandDetail''),ROOT(''ProductDistributionBrandDetails''),TYPE'    
--select @sql
set @sql2 = exec(@sql)  
select @sql2            
</code></pre>