Solved

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

Posted on 2006-11-03
1
834 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
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

803 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