Solved

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

Posted on 2013-11-18
8
335 Views
Last Modified: 2013-11-18
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!!
0
Comment
Question by:Silas2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 7

Expert Comment

by:valmatic
ID: 39657213
why the comma at the end of line 2?
0
 
LVL 26

Expert Comment

by:Shaun Kline
ID: 39657216
I believe the ability to insert multiple sets of values is available in SQL Server 2008 and up.
0
 
LVL 9

Expert Comment

by:QuinnDex
ID: 39657217
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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 26

Expert Comment

by:Shaun Kline
ID: 39657224
To do what you are attempting in SQL Server 2005, you will need to use the SELECT / UNION / SELECT trick.
0
 

Author Comment

by:Silas2
ID: 39657246
Ah, maybe a search/replace on ",(" for 'Values (' would work then...?
0
 
LVL 9

Accepted Solution

by:
QuinnDex earned 250 total points
ID: 39657255
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
 

Expert Comment

by:jayhawker95
ID: 39657264
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
 

Author Comment

by:Silas2
ID: 39657280
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question