Link to home
Start Free TrialLog in
Avatar of Silas2
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:
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!!
Avatar of valmatic
valmatic
Flag of United States of America image

why the comma at the end of line 2?
Avatar of Shaun Kline
I believe the ability to insert multiple sets of values is available in SQL Server 2008 and up.
Avatar of QuinnDex
QuinnDex

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 ')
To do what you are attempting in SQL Server 2005, you will need to use the SELECT / UNION / SELECT trick.
Avatar of Silas2

ASKER

Ah, maybe a search/replace on ",(" for 'Values (' would work then...?
ASKER CERTIFIED SOLUTION
Avatar of QuinnDex
QuinnDex

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of Silas2

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....