Correct syntax to add multiple rows to a table.....?

What is the correct syntax to use for this INSERT..???

I'm getting this error:

Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'values'.



insert into dbo.media_expense  (media_date, media_cost)
values ( '2008-10-20',3819.00)
values ('2008-10-21',3832.00)
values  ('2008-10-22',3809.00)
values  ('2008-10-23',3784.00)
values  ('2008-10-24',4214.00)
values  ('2008-10-25',0.00)
values  ('2008-10-26',0.00)
values  ('2008-10-27',4191.00)
values  ('2008-10-28',3954.00)
values  ('2008-10-29',4034.00)
values  ('2008-10-30',3808.00)
values  ('2008-10-31',4129.00)
values  ('2008-11-01',0.00)
values  ('2008-11-02',0.00)
values  ('2008-11-03',3639.00)
values  ('2008-11-04',4969.00)
values  ('2008-11-05',5074.00)
values  ('2008-11-06',5129.00)
values  ('2008-11-07',5504.00)
values  ('2008-11-08',0.00)
values  ('2008-11-09',0.00)
LVL 17
MIKESoftware Solutions ConsultantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kevin CrossChief Technology OfficerCommented:
You will have to do multiple INSERT statements or use UNION ALL syntax.
0
MIKESoftware Solutions ConsultantAuthor Commented:
HOW please..???
0
Kevin CrossChief Technology OfficerCommented:
Like this with UNION...
insert into dbo.media_expense (media_date, media_cost)
select  '2008-10-20',3819.00
union all select '2008-10-21',3832.00
union all select '2008-10-22',3809.00
...

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kevin CrossChief Technology OfficerCommented:
Like this with multiple statements...
insert into dbo.media_expense (media_date, media_cost)
values ('2008-10-23',3784.00)
insert into dbo.media_expense (media_date, media_cost)
values ('2008-10-24',4214.00)
insert into dbo.media_expense (media_date, media_cost)
values ('2008-10-25',0.00)
...

Open in new window

0
Kevin CrossChief Technology OfficerCommented:
I don't have my SQL Studio handy, but if you have the above in SQL Management Studio, just do a find and replace on "values (" and replace with "UNION ALL SELECT ", then replace ")" with "".  Do this replacement on selection outside of INSERT INTO... line.

This will quickly allow you to change what you have to single statement.  You will just have to remove the UNION ALL from first select so it looks like my sample.

Hope that helps.

Kevin
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.