Hi John
There are several ways to do this. Here's one of them. Once you add the
ExpiryDate column, you can use the following sql query:
SELECT Name, Subject, [Date], Message, messageID, ExpiryDate, 1 AS
OrderFlag
FROM dbo.Messages
WHERE ([ExpiryDate] >= GETDATE())
UNION
SELECT Name, Subject, [Date], Message, messageID, ExpiryDate, 2 AS
OrderFlag
FROM dbo.Messages
WHERE ([Date] > GETDATE() - 7)
ORDER BY OrderFlag ASC
Hopefully this is what you are looking for.
Lucas
> Hello all,
>
[quoted text clipped - 16 lines]
> Many thanks,
> John
John Thorn - 30 May 2006 14:00 GMT
Hi Lucas
This code looks to me like it will do the job, but I still need further
help: When I whack it in to SQL Query Analyser and parse, it returns:
Server: Msg 8163, Level 16, State 1, Procedure LastFewEntries, Line 4
The text, ntext, or image data type cannot be selected as DISTINCT.
I had to alter the SELECT lines to SELECT TOP 100 PERCENT Name,..... because
it was complaining about the ORDER BY.
Many thanks in advance,
John
> Hi John
>
[quoted text clipped - 40 lines]
>> Many thanks,
>> John