Hi,
If I write a sproc in this format, will sql server do this effeciently or should the sql 'weaving' be done on the server side (.net)?
Note: this is just a rough idea of what my query looks like, there are more 'if' clauses the build up my query that I execute using 'exec'
declare @sql nvarchar(4000)
declare @order nvarchar(4000)
set @sql = 'select id, name'
set @sql = @sql + ' ....'
if(@sortOrder)
set @order = 'order by name desc'
exec @sql + @order