Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2010

    Unanswered: Hopefully an easy one.

    Hi, I have seen a couple of similar ones on these boards and have tried a few Google searches to try fix this.

    If someone could help me figure this out that would we very much appreciated. I'm new to this type of DB work so if any clarification is needed just let me know.

    I have a table that populates each night with database sizes etc...

    This is the select statement that gives all columns.

    SELECT [ServerName]
    FROM [ReportServer].[dbo].[DBINFORMATION]

    I can easily run a pivot table or report on all the daily data but would really like to be able to pull out just something for the first day of each month eg..

    SELECT *all of the above*
    WHERE [Date] = '2010/07/01' OR [Date] = '2010/06/01' .....

    I'm guessing there is an easier way than putting in each month??
    Is there a way to do this for each week as well?
    Any help would be great!

  2. #2
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    See DatePart().
    SELECT   [ServerName]
    ,  [DatabaseName]
    ,  [LogicalFileName]
    ,  [PhysicalFileName]
    ,  [FileSizeMB]
    ,  [FileSizeGB]
    ,  [Status]
    ,  [RecoveryMode]
    ,  [FreeSpaceMB]
    ,  [FreeSpacePct]
    ,  [Date]
       FROM [ReportServer].[dbo].[DBINFORMATION]
       WHERE 1 = DatePart(day, [Date])
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Jul 2010



    That was fast. Thanks for the help. I knew it had to be something straight forward as I was sure I wasn't the first person to need that in SQL.

    Much appreciated!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts