Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2007-11-14
4
Medium Priority
?
1,545 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
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
cezarF earned 1000 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
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 SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

916 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