I'm staring at this, but i can't see whats wrong???

SQL server (express 2005), I cannot see what's wrong with this:
INSERT INTO uk_postcodes (postcode, x, y, latitude, longitude, town, county) VALUES
('AB10', 392900, 804900, '57.13', '-2.11', 'Aberdeen ', 'Aberdeen '),
('AB11', 394500, 805300, '57.13', '-2.09', 'Aberdeen ', 'Aberdeen ')

Open in new window

First line goes in OK, but with both, I keep getting an error on a comma,
I'm going blind or mad or both!!
Silas2Asked:
Who is Participating?
 
QuinnDexConnect With a Mentor Commented:
syntex needed

INSERT INTO MyTable (FirstCol, SecondCol)
SELECT 'First' ,1
UNION ALL
SELECT 'Second' ,2
UNION ALL
SELECT 'Third' ,3
UNION ALL
SELECT 'Fourth' ,4
UNION ALL
SELECT 'Fifth' ,5

Open in new window

0
 
valmaticCommented:
why the comma at the end of line 2?
0
 
Shaun KlineLead Software EngineerCommented:
I believe the ability to insert multiple sets of values is available in SQL Server 2008 and up.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
QuinnDexCommented:
INSERT INTO uk_postcodes (postcode, x, y, latitude, longitude, town, county) VALUES
('AB10', 392900, 804900, '57.13', '-2.11', 'Aberdeen ', 'Aberdeen ')
('AB11', 394500, 805300, '57.13', '-2.09', 'Aberdeen ', 'Aberdeen ')
0
 
Shaun KlineLead Software EngineerCommented:
To do what you are attempting in SQL Server 2005, you will need to use the SELECT / UNION / SELECT trick.
0
 
Silas2Author Commented:
Ah, maybe a search/replace on ",(" for 'Values (' would work then...?
0
 
jayhawker95Commented:
I do not see anything wrong with your code:

INSERT INTO uk_postcodes (postcode, x, y, latitude, longitude, town, county) VALUES
('AB10', 392900, 804900, '57.13', '-2.11', 'Aberdeen ', 'Aberdeen '),
('AB11', 394500, 805300, '57.13', '-2.09', 'Aberdeen ', 'Aberdeen ')

I have run it thru numerous statement analyzers and all report no errors.
0
 
Silas2Author Commented:
Phew what a palava, QuinnDex is right, it doens't work in 2005. I had to do a search/replace on '(' for 'select ' and ')' for ' union all ' but at least it worked....
0
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.

All Courses

From novice to tech pro — start learning today.