Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating rows for each of current month

Status
Not open for further replies.

Lftsk

Programmer
Jul 11, 2002
25
US
Hello,

please forgive me if this is stupid, but I was wondering if anybody knows or has a simple way of inserting a row for each of the current month into a table? Can I do this without a looping construct in a stored?

Thank you.
 
I'm not clear abt your question!

do u want to populate a table with all the months starting from 1 to 12? if so this is one way to do it.

Create Table #TEMP (month1 tinyint)

Declare @i int
set nocount on
SET @i=1
while @i<=12
begin
insert into #temp (month1) values(@i)
set @i=@i+1
end
set nocount off
select * from #temp
GO
DROP TABLE #TEMP


dbtech
 
Sorry. I left out a word. I meant to say for each DATE of the current month.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top