Solved

Specific years 1998 to current years into a temp table SQL Server

Posted on 2011-03-02
2
200 Views
Last Modified: 2012-05-11
I want to create a stored  procedure that will give me the years from 1998 till the current year and put the values into a temp table.  This should be easy but am not getting the right thought process going. please help
0
Comment
Question by:etan08
2 Comments
 
LVL 15

Accepted Solution

by:
derekkromm earned 125 total points
ID: 35017344
If you're just trying to put "1998", "1999", ..., "2011" into a temp table, but want it dynamic, its going to be easiest to just do this:

declare @yr int
select @yr = 1998
while @yr <= (select year(getdate()))
begin
    insert into <tbl> select @yr
    select @yr = @yr + 1
end
0
 

Author Closing Comment

by:etan08
ID: 35017551
Thanks
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to shrink a transaction log file down to a reasonable size.

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now