I have a large dynamic sql in order to insert dynamic operators such as less than and greater than.Most parameters are set = NULL because in the where clause it's needed for a proper search such as:WHERE cost = @cost OR @cost IS NULL
The string will not work if the parameter is null such as:DECLARE @test INT = NULLDECLARE @sql VARCHAR(MAX)SET @sql = 'SELECT SomeCol FROM myTable WHERE someID = ' + CONVERT(VARCHAR(100), @test)print @sql
But if @test is set to 1, it prints just fine and will execute using exec (@sql)Is there a way around these null values to build a dynamic sql?Thanks