Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Data extrapolation on the fly

By Mohit Nayyar,

In some cases we need to generate the data based on a starting date, to an end data (today-getdate()). This process is called data extrapolation based on limited information (starting date).

Here I am trying to achieve the same without storing data in temp./staging tables.

First I am creating a temp. table wih 2 rows and now I need to generate rest of the rows starting from given date to today's date.

Next step is to make use of CTE to generate sequence of rows and finally making use of CROSS JOIN to join the sequence with real data and get the desired output.

Thanks
Mohit Nayyar

Total article views: 805 | Views in the last 30 days: 2
 
Related Articles
FORUM

Generic Service SQL Server Fulltext Failed to start service. Error: 1053

Generic Service SQL Server Fulltext Failed to start service. Error: 1053

BLOG

How wait statistics are generated

How wait statistics are generated In our last article “Why wait statistics are important and how ...

FORUM

Best code for generating sequence numbers

Sequence generation

SCRIPT

Auto generation key field

Auto generation key field

SCRIPT

CRUD generator

Script to generate create, read, update, and delete scripts for a table.

Tags
t-sql    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones