Solved

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

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

813 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

14 Experts available now in Live!

Get 1:1 Help Now