I have a set of 100 races. Different races are sanctioned by different bodies. So I have a event_sanction table that holds the eventid and the sanctionerid. One sanctioner is good for all 100 races. Is there a way to mass insert that sanctioner? INSERT
INTO event_sanction (eventid, sanctionid) VALUES ((ALL EVENT ID's) , 1)?
dieseldave
Member
384 Points
432 Posts
Multiple Insert
Feb 26, 2012 02:05 AM|LINK
I have a set of 100 races. Different races are sanctioned by different bodies. So I have a event_sanction table that holds the eventid and the sanctionerid. One sanctioner is good for all 100 races. Is there a way to mass insert that sanctioner? INSERT INTO event_sanction (eventid, sanctionid) VALUES ((ALL EVENT ID's) , 1)?
Thanks
budugu
All-Star
41110 Points
6020 Posts
Re: Multiple Insert
Feb 26, 2012 02:26 AM|LINK
You can use While loop in SQL Script. like this..
While @Eventid <= 100 Begin --Insert statement here.. SET @Eventid = @Eventid + 1 End"Don't be afraid to be wrong; otherwise you'll never be right."
Dan Bracuk
Contributor
3970 Points
1096 Posts
Re: Multiple Insert
Feb 26, 2012 02:28 AM|LINK
insert into event_sanction
(eventid, sanctionid)
select eventid, @sanctionid
from somewhere