Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8207947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:10:16+00:00 2026-06-07T09:10:16+00:00

I have been working on an SQL Statement in which I can select a

  • 0

I have been working on an SQL Statement in which I can select a start date and end date and add all the dates in between into the table. This start and end date is accompanied by an id. Like for example I select 1/1/2012 and 4/1/2012 and the id is 1
the result should be as follow

reqId   reqDate
1       1/1/2012
1       2/1/2012
1       3/1/2012
1       4/1/2012

My sql statement is as follow

"Insert into Request(reqId, reqDate) " & _
"Select @request, reqDate From Request where reqDate between @start and @end "

It just does nothing so I am not sure if I am on the right track.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T09:10:17+00:00Added an answer on June 7, 2026 at 9:10 am

    Not knowing what database system you’re using, here’s one for SQL Server (2008 or later):

    declare @Start date
    declare @end date
    declare @request int
    
    set @Start = '20120101'
    set @end = '20120104'
    set @request = 1
    
    ;with Dates as (
        select @request as reqId,@Start as reqDate
        union all
        select reqId+1,DATEADD(day,1,reqDate) from Dates
        where reqDate < @end
    )
    select * from Dates
    

    Result:

    reqId       reqDate
    ----------- ----------
    1           2012-01-01
    2           2012-01-02
    3           2012-01-03
    4           2012-01-04
    

    (I originally said for 2005 or later, then realised I’m using date. For 2005, replace date with datetime)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working with SQL Server as a Developer a while. One thing
we have WinForms app which stores data in SQL Server (2000, we are working
I have been playing around with a quite complex SQL Statement for a few
I have not been working in SQL too long, but I thought I understood
I am working on a SQL Statement that I can't seem to figure out.
T-SQL Paging Sorting & Filtering I have been working on a T-SQL stored procedure
I have been recording Twitter data for a project I'm working on the date
Recently I have been working with a SQL Server database and I was trying
On Sql Server 2008, I have a slow-running update query that has been working
Have been working on this question for a couple hours and have come close

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.