Solved

Insert multiple  rows into a table in SQL Server 2000 using SQL

Posted on 2007-11-14
4
1,539 Views
Last Modified: 2010-08-05
I am trying to build a sql that can enter multiple rows into a table

Insert into dbo.mcsso_LBCityUserMapping (PortalUserID,LBCityUsername,Created,LastModified,LastModifiedBy)
Values (120855,'grulaa2',11/14/2007,11/14/2007,103884)
Values (120861,'korenovab1',11/14/2007,11/14/2007,103884)

Get teh error message.

Server: Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'Values'.
0
Comment
Question by:Sanjeet
[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
4 Comments
 
LVL 14

Accepted Solution

by:
cezarF earned 250 total points
ID: 20286231
try ...

Insert into dbo.mcsso_LBCityUserMapping (PortalUserID,LBCityUsername,Created,LastModified,LastModifiedBy)
(SELECT 120855,'grulaa2',11/14/2007,11/14/2007,103884
UNION
SELECT 120861,'korenovab1',11/14/2007,11/14/2007,103884)
0
 

Author Comment

by:Sanjeet
ID: 20286244
That worked, if I want to keep adding rows after the second one do I keep just adding a union clause?
0
 
LVL 14

Expert Comment

by:cezarF
ID: 20286248
yup
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 20286265
in sql server 2008  this will also work

Insert into dbo.mcsso_LBCityUserMapping (PortalUserID,LBCityUsername,Created,LastModified,LastModifiedBy)
Values (120855,'grulaa2',11/14/2007,11/14/2007,103884) , (120861,'korenovab1',11/14/2007,11/14/2007,103884)
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

752 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