473,399 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Error in inserting multiple records

4
Hi,
I am getting error as below while inserting multiple records in table

Code : INSERT INTO Management.Departments(DepartmentCode, Name)
VALUES(N'ITEC', N'Information Technology'),
(N'PRSN', N'Personnel');

Error code : Msg 102, Level 15, State 1, Line 3 Incorrect syntax near ','.

My MS SQL server version is:-
Microsoft SQL Server 2005 - 9.00.5000.00 (Intel X86)
Dec 10 2010 10:56:29
Copyright (c) 1988-2005 Microsoft Corporation
Express Edition on Windows NT 6.1 (Build 7601: Service Pack 1)

compatibility level 90
Please help me that why I am not able to insert multiple records and how this problem can be solved?
Nov 3 '11 #1
9 2770
ck9663
2,878 Expert 2GB
Try removing those Ns

Happy Coding!!!


~~ CK
Nov 3 '11 #2
akhush
4
Hi,

Thanks for replying me. However the checked by removing Ns still it is not working.
Nov 4 '11 #3
Rabbit
12,516 Expert Mod 8TB
Don't think you can insert multiple records that way.
Nov 4 '11 #4
akhush
4
Hi,

No I am able to insert multiple records as I mentioned earlier...
Nov 4 '11 #5
Rabbit
12,516 Expert Mod 8TB
No... you said you're getting an error trying to insert multiple records using that syntax. You didn't say you were able to insert multiple records. Otherwise, you have no question.
Nov 4 '11 #6
ck9663
2,878 Expert 2GB
Oooppss, sorry I missed that. I don't think you can insert rows that way. If you want you can use UNION ALL to combined those two rows that you are trying to insert.

Happy Coding!!!


~~ CK
Nov 4 '11 #7
akhush
4
Sorry i missed "not" in my last conversation...I am not able to insert records through the query i mentioned above.
Even i tried union all in last it did not worked.
Nov 4 '11 #8
Maraj
24
Try like this it will work if your data types are char or varchar for both columns.

INSERT INTO Management.Departments(DepartmentCode, Name)
VALUES('ITEC', 'Information Technology'),
('PRSN', 'Personnel')
Nov 5 '11 #9
ck9663
2,878 Expert 2GB
You can either do two insert statements, or do a UNION ALL. Can you post the UNION ALL code that you did so we can see why it failed?


~~ CK
Nov 5 '11 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Ramesh | last post by:
hi I am trying to insert 50,000 random records in the SQL server. I have created COM for inserting records. When i started inserting, after 44152 records it displayed following error message. "...
5
by: Brian | last post by:
I need help PLEASEEEEEEEEEEEEEEE..... I am trying to create a list of questions that have yes/no answers. There are 8 groups of questions. Based on who the user is that logs in will determine...
12
by: shank | last post by:
I'm trying to use online samples for submitting multiple records from ASP into a stored procedure. Failing! Through the below form, a user could be submitting many records at a time. I'm not...
7
by: flashguy | last post by:
Hi, Looking online for this related topic that will be exclusively used for MS ACCESS (2000 preferably) is extremely limited. Is it possible to add Multiple records with one click of a buttton...
0
chumlyumly
by: chumlyumly | last post by:
Hello scripters - OS: Mac OSX Language: PHP w/ MySQL database I've created an insert page where a user inputs his info, which then goes to four different tables in a MySQL database. The...
2
by: tamimmakki | last post by:
hi, i have to add names of 11 players of a team into database table 'tbl_players'. so i put 11 text boxes in form with a submit button. I tried it with a for loop but its not working. I am working in...
0
by: t8ntboy | last post by:
ASP/SQL Server Express 05 I have two tables, A and B. I would like to insert multiple records into both form A and B, but a field in form B is the Record ID in form A. So, I need to insert the...
1
by: xixor | last post by:
I work for a nonprofit organization that allows individuals to sponsor children overseas. Some of these sponsors decide to become volunteers and speak at their church, university, or other event to...
1
by: sreenu123 | last post by:
How to insert multiple records into a database table that are entered into a datagridview. With a single shot of Save all the records in the datagridview should be updated using C# . Can any one help...
7
by: wozza | last post by:
hi I'm a Dreamweaver user who's created a few simple data entry/ registrations forms in my time, but I'm not really a coder (though I can follow instructions and am not afraid to dabble...) - I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.