SQL Server Incremental Years Value

| by RANA | May 17, 2008
I am unable to find something good and fast where without involving master database years value in the sql server. I found below query but I dont wanted to involve master databaseSELECT TOP 11000 –equates to more than 30 years of dates
IDENTITY(INT,1,1) AS N
INTO dbo.Tally
FROM Master.dbo.SysColumns sc1,
Master.dbo.SysColumns sc2

Here is something i made simple and fast.

DECLARE @TILL INT — define your end year value I am taking till 2008 + 2 = 2010

SET @TILL = YEAR(GETDATE())+2

DECLARE @FIRSTVALUE INT

SET @FIRSTVALUE=2001 - declaring first value

CREATE TABLE #TEMP
( .......
http://blog.joggee.com/?p=165
The author of Blog.Joggee is the same person of the Rana Blog in the codeproject.wordpress.com.The reason why this new blog was created because Rana wanted to share more diverse range of services such as the latest technology, variation of ideas and universal advice in more user friendly and customizable way.Join and become a part of an international community dedicated to excellence, service and knowledge creation.

Article Source: http://www.articleset.com



About the Author

The author of Blog.Joggee is the same person of the Rana Blog in the codeproject.wordpress.com. » Read more articles by RANA
You are welcome to publish or reprint this article free of charge, provided: