CREATE PROCEDURE dbo.fetch_technologies @is_billable varchar(10) = '0',
@whereCondition nvarchar(max) = ''
AS
BEGIN
	declare @select_query nvarchar(max) = '';

	SET @select_query = 'SELECT tech_id,tech_name,is_billable,category_order,bu_id FROM dim_technologies as tech
				left join mis_bu_technology as bu_tech
				on bu_tech.technology_id = tech.tech_id where 1=1 ';

	IF  @is_billable = '1'
        BEGIN
            SET @select_query = @select_query + ' and is_billable = ' + @is_billable;
        END
	IF @whereCondition != ''
	    BEGIN
            SET @select_query = @select_query  + @whereCondition
        end
    SET @select_query = @select_query + ' order by category_order asc';
-- 	PRINT @select_query;
    EXEC sp_executesql  @select_query;
END;
go

