I have the following funciton working fine although I want to modify it so that it runs a select statement first that checks if the Builder's status is awarded.
From there I want to have an if statement to run either the below select statment or a differnet one based on whether or not hte builder is awarded.
ALTER FUNCTION [dbo].[fnBuildersByProject]
(@ProjectID int , @PID int )
declare @List varchar(1000)
SELECT @List = COALESCE(@List + ', ', '') + ltrim(rtrim(convert(varchar,BuilderCompany)))
WHERE Builders.projectID = @ProjectID
ORDER BY Builders.BuilderCompany