Re: Is there anything like DoEvents in a stored proc?
From: David Portas (REMOVE_BEFORE_REPLYING_dportas_at_acm.org)
Date: 05/10/04
- Next message: Paul S Randal [MS]: "Re: text columns"
- Previous message: anonymous_at_discussions.microsoft.com: "Re: Reporting Services"
- In reply to: Randy Danielson: "Re: Is there anything like DoEvents in a stored proc?"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 10 May 2004 22:36:59 +0100
You want (at most) the top 104000 rows by date but only complete months? Try
this:
DECLARE @dt DATETIME
SET ROWCOUNT 104001
SELECT @dt = DATEADD(MONTH,DATEDIFF(MONTH,-1,xdate),0)
FROM SomeTable
ORDER BY xdate DESC
SET ROWCOUNT 0
SELECT *
FROM SomeTable
WHERE xdate >= @dt
I'll be the first to admit that this is far from perfect. It uses a
proprietary, undocumented trick that isn't guaranteed to work in future
versions of SQLServer. I'm sure there are better methods of getting the
result you need but without a full understanding of your business
requirements this is just intended to illustrate one possibility.
-- David Portas SQL Server MVP --
- Next message: Paul S Randal [MS]: "Re: text columns"
- Previous message: anonymous_at_discussions.microsoft.com: "Re: Reporting Services"
- In reply to: Randy Danielson: "Re: Is there anything like DoEvents in a stored proc?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|