Hi,
Is it possible to do this without using a stored procedure or alot of custom code...
ALTER PROCEDURE [dbo].[sp_GetTopLifeNStuffCategory]
@Date as datetime
AS
SELECT
c.LifeNStuffCategoryID,
Title,
Ordinal,
LifeNStuffPriorityID,
CASE WHEN startdate IS NULL THEN NULL ELSE 1 END AS 'IsPriortiy'
FROM
tbl_lifenstuff_category c
LEFT JOIN
tbl_Lifenstuffpriority p
ON
c.LifeNStuffCategoryID = p.LifeNStuffCategoryID
AND
p.startdate <= @Date AND p.enddate > @Date
ORDER BY
IsPriortiy DESC,
ordinal
Its the 'case' statement that's the problem.
Cheers, Ian.