RE: write a stored procedure which return all record for last month

From: Cowboy (Gregory A. Beamer) - MVP (NoSpamMgbworld_at_comcast.netNoSpamM)
Date: 11/04/04


Date: Wed, 3 Nov 2004 19:31:03 -0800

If you want everything for a month, you are most of the way there. Getting
the MAX(Date) is a good start. Next, you will want to use the MONTH() and
YEAR() functions to get all records where the Month of the date = max(date)'s
month and the year matches max(date)'s year. This will only give you records
for a single month.

---
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
***************************
Think Outside the Box!
***************************
"Lloyd Dupont" wrote:
> I have a blog_text table with a date column.
> I'm trying to write a stored which find the month ot the last entry, and the 
> return all records for the month.
> I'm quite new to stored procedure, can't find relevant infomation in the 
> documentation, and I'm not managing it....
> 
> If anyonw could gives me any hinth on why the below code is wrong and how to 
> make it both
> - compile
> - return last month entries...
> thanks ;-)
> ---------
> CREATE PROCEDURE dbo.LastBlogMonth AS
> 
> DECLARE @max_date DATETIME
> 
> SELECT @max_date = MAX([date]) FROM galador_blog_text
> GO
> 
> SELECT * FROM galador_blog_text
> WHERE [date] >= @max_date
> RETURN
> 
> GO 
> 
> 
> 


Relevant Pages

  • Re: scope_identity() issues.
    ... Using Dynamic SQL is not a very good practice in .NET Here is an ... example of a stored procedure that does what you are trying to do. ... There is a column in this table named ID which is an identity column. ... Study your VB documentation regarding Parameterized Commands. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Creating and calling stored procedure
    ... an answer to in the documentation. ... I want to write a simple stored procedure in PL/SQL with one input ... how do I specify them in the call (execute) ...
    (comp.databases.oracle.misc)
  • Re: Using the Fill Method with Stored Procedure
    ... The documentation only talks about using a SQLDataAdapter or ... Is it possible to use a stored procedure to fill a ...
    (microsoft.public.dotnet.framework.adonet)