Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
echo33
Starting Member
1 Post |
Posted - 2011-03-29 : 07:47:11
|
| Hi guys, new here because i am struggling massively lol.What i need to do is run instert the same thing into a database only changing the date.i.eNSERT INTO bs_events (eventDate,eventTime,title,spaces,description,entryFee,payment_required,max_qty,allow_multiple) VALUES ('2011-03-02 00:00:00', '10:00','Carpet Cleaner 3000','4','This is rad','25.99','1','1','2') so i need to run this loop for a year or month or 2 years and have it add to the database but the date needs to change each dayI've got no idea how I go about making a script to do this so any help would be appreciated thanksecho33 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-03-29 : 08:24:33
|
make use of a tally or number tableinsert into bs_events (eventDate, eventTime, . . . )select eventDate = dateadd(month, number, '2011-03-02'), eventTime = '10:00', title = 'Carpet Cleaner 3000', . . . from master..spt_valueswhere type = 'P'and number between 0 and 11 KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|
|