Solved

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

Posted on 2007-11-14
4
1,533 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 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how the fundamental information of how to create a table.

706 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

17 Experts available now in Live!

Get 1:1 Help Now