Silas2
asked on
I'm staring at this, but i can't see whats wrong???
SQL server (express 2005), I cannot see what's wrong with this:
I'm going blind or mad or both!!
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 ')
First line goes in OK, but with both, I keep getting an error on a comma, I'm going blind or mad or both!!
why the comma at the end of line 2?
I believe the ability to insert multiple sets of values is available in SQL Server 2008 and up.
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 ')
('AB10', 392900, 804900, '57.13', '-2.11', 'Aberdeen ', 'Aberdeen ')
('AB11', 394500, 805300, '57.13', '-2.09', 'Aberdeen ', 'Aberdeen ')
To do what you are attempting in SQL Server 2005, you will need to use the SELECT / UNION / SELECT trick.
ASKER
Ah, maybe a search/replace on ",(" for 'Values (' would work then...?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
ASKER
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....