Solved

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

Posted on 2013-11-18
8
318 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
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 7

Expert Comment

by:valmatic
Comment Utility
why the comma at the end of line 2?
0
 
LVL 25

Expert Comment

by:Shaun Kline
Comment Utility
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
Comment Utility
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
 
LVL 25

Expert Comment

by:Shaun Kline
Comment Utility
To do what you are attempting in SQL Server 2005, you will need to use the SELECT / UNION / SELECT trick.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

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

Accepted Solution

by:
QuinnDex earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now