Solved

Create a View with every day of the month, programmatically in SQL

Posted on 2006-11-03
1
836 Views
Last Modified: 2010-10-05
Experts,

I've got a table that shows Begin_Date, End_Date, Exchange_Rate.  The rate may change weekly.

I'd like to create a view that lists every day of the month, with the exchange rate shown for that day.

Can you think of a way, in using SQL code, I can SELECT every day of the month, and link it to my Exchange Rate table?
0
Comment
Question by:AptDev
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 10

Accepted Solution

by:
AaronAbend earned 500 total points
ID: 17870191

declare @adate datetime
declare @monthno int
begin

set @adate='11/01/2006' - seed with a date
set @monthno = datepart(mm,@adate)

while (datepart(mm,@adate)=@monthno)
  begin
  select exchangerate from table1 where adate=@adate
  set @adate=dateadd(d, 1, @adate)

  end
end

0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have a large data set and a SSIS package. How can I load this file in multi threading?
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question