一次插入多个记录-sql server 2008 [英] inserting multiple records at once-sql server 2008

查看:82
本文介绍了一次插入多个记录-sql server 2008的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在sql server 2008 express中一次插入多条记录。我有一个名为enrolnment的表,有三个字段,即pupilcode,year,grade.Pupilcode字段使用asp.net checkedlistbox conrol绑定,year使用asp.net dropdownlist控件绑定,使用asp.net dropdownlist控件绑定等级。注释数据已经预先填写在表格中。

How can i insert multiple records at once in sql server 2008 express. I have a table called enrolnment with three fields namely pupilcode,year,grade.Pupilcode field is bound using asp.net checkedlistbox conrol, year is bound using asp.net dropdownlist control and grade is bound using asp.net dropdownlist control. Note data is already prepopulated in the table.

    PupilCode	                Year	Grade
2010105350020004	                2008	2
2010105350020005		
2010105350020006		
2010105350020007		
2010105350020008		
2010105350020009		



如果我点击一个按钮(多个条目),如何将同年,同一年级插入其他记录已经检查了checkedlistbox中的所有内容,以便它变成如下所示;




How can I insert same year,same grade to the other records at a click of a button(multiple entry) if I have checked all in the checkedlistbox so that it becomes like below;

PupilCode	Year	Grade
2010105350020004	2008	2
2010105350020005	2008	2
2010105350020006	2008	2
2010105350020007	2008	2
2010105350020008	2008	2
2010105350020009	2008	2



当我使用插入ernolnment(pupilcode,年份,年级)值(pupilcode,年份,等级)它只插入第一条记录。我该如何实现这一目标。我希望这有助于批处理,而不是用户按记录更新记录。


When i use insert into ernolnment (pupilcode,year,grade)values(pupilcode,year,grade)it only insert the first record. how do i achieve this. I want this to help in batch process rather than users be updating a record by record.

推荐答案





您可以使用UDT(用户定义类型)作为SP的表参数。然后你可以一次性传递所有记录。请检查以下示例。你会清楚地了解这个过程(前端和后端)。

将DataTable发送到存储过程 [ ^ ]

问候,

GVPrabu。
Hi,

You can use UDT (User Define Type) as Table Perameter for SPs. Then u can pass all records in onee time. Check the following Example. You will get clear Idea about this Process (Front end and Backend).
Sending a DataTable to a Stored Procedure[^]
Regards,
GVPrabu.


这篇关于一次插入多个记录-sql server 2008的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆