Update: Microsoft will be moving away from UserVoice sites on a product-by-product basis throughout the 2021 calendar year. We will leverage 1st party solutions for customer feedback. Learn more here.

Michal Dobšovič

My feedback

  1. 235 votes

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    8 comments  ·  SQL Server » Suggestions  ·  Flag idea as inappropriate…  ·  Admin →

    Upvotes: 278

    <=-=Feb 1 2008 7:18PM=-=>

    Thanks for the valuable suggestion.

    This seems more like adding the sequence support which we’re seriously considering for the next major release.

    Meanwhile, would using identity column help?

    <=-=Feb 2 2008 2:11AM=-=>

    It does not seem that you understood the request. This definitely has nothing to do with
    IDENTITY. I am less versed about sequences, but I don’t think they will cut it either. If you think
    it does, maybe you could provide an example? Take this problem: For the Orders table in
    Northwind, write a query that lists the number of orders for all days in 1997. The result set should
    include all 365 days, and list zero for days without a number.

    This is a typical problem where you need a table of of numbers (or dates). While it’s easy to
    create such a table, I argue in this request that…

    An error occurred while saving the comment
    Michal Dobšovič commented  · 

    You can use Common Table Expressions for this:

    DECLARE @StartDate date = '2015-10-01',
    @EndDate date = '2016-11-01'
    ;
    WITH cte AS (
    SELECT CASE WHEN DATEPART(Day,@StartDate) = 1 THEN @StartDate
    ELSE DATEADD(Month,DATEDIFF(Month,0,@StartDate)+1,0) END AS myDate
    UNION ALL
    SELECT DATEADD(Month,1,myDate)
    FROM cte
    WHERE DATEADD(Month,1,myDate) <= @EndDate
    )
    SELECT myDate
    FROM cte
    OPTION (MAXRECURSION 0)

  2. 561 votes

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    25 comments  ·  SQL Server » Suggestions  ·  Flag idea as inappropriate…  ·  Admin →
    Michal Dobšovič supported this idea  · 

Feedback and Knowledge Base