Solved

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

Posted on 2013-11-18
8
328 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
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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Merige returns error code when updating 15 54
insert query with value having 's 2 57
SQL Encryption question 2 61
display data in text field from data base for updating 6 65
There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

808 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