It looks like the need to use dynamic SQL is unavoidable with SQL Server for different reasons but the resulting code looks convoluted and unmaintainable. SQL server management studio's intellisence stops working for queries inside literals and overall with all this string manipulation stuff it's a mess IMO.
What are your approaches to simplifying this and making the SQL more maintainable?
(except of course not using SQL directly at all and relying on an ORM which is not an option in my current situation)
Edit: In my current particular case I have an SP with several filtering parameters that are used in the where clause with like, when a parameter is null or empty it should not be included in the where clause, trying to avoid dynamic sql with (@param IS NULL) OR (column LIKE @param)
leads to poor performance.