Michal Dobšovič

My feedback

  1. 137 votes
    Sign in
    (thinking…)
    Sign in with: Microsoft
    Signed in as (Sign out)

    We’ll send you updates on this idea

    7 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…

    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. 357 votes
    Sign in
    (thinking…)
    Sign in with: Microsoft
    Signed in as (Sign out)

    We’ll send you updates on this idea

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

Feedback and Knowledge Base