如何一次更新并插入多行? [英] How to update and insert multiple rows at once?

查看:67
本文介绍了如何一次更新并插入多行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我的要求如下:
在单个网页中,我有一个图像滑块[JQuery]类型控件.当我单击任何特定图像时,所有相关信息都在下面的[text box]字段中.
有两种情况:
1.我可以更改文本框中的值.再次选择另一张图像,更改文本框中的相关信息.这种方式.但是我想通过单击一个按钮来更新所有信息,而不是每次都单击.[批量更新]
2.可能有空白图像,我必须为其提供新的信息.[如果不存在该信息,请批量插入].

只需单击一下按钮,我将做的两件事.
现在我的问题是:
我想编写一个sp,如果不存在该行,它将批量插入;如果存在,它将更新该行.
如何为&b;批量插入/更新</b>编写这样的SP?对于单行,我可以做到.
[假定表结构:(Mov_id pk,Mov_name,Cost)应该是这样的:
如果Mov_id不在table_Movie中
插入....
否则,更新table_Movie set .... where ...]这是针对单行的.我想批量执行.
请紧急帮助我..

解决方案

您可以使用XML输入参数并在SP中使用OPENXML.

Hi,
My requirement is as follows:
In a single web page I have a image slider[JQuery] type control.When I am clicking on any particular image,all the related information are coming in the fields[text boxes]below.
there are two scenarios:
1.I can change the values in the text boxes.Again select another image,change the related infos the text boxes.this way.But I want to update all the information by clicking one button,not every time.[Bulk Update]
2.There may be blank image,for which I have to give new information.[bulk Insert in case the info is not existing].

Both the things I will do on a single button click.
Now my question is:
I want to write a sp which will bulk insert if the row was not present or it will update the row if present.
How to write such SP for <b>bulk Insert/Update</b>?For single row,I can do.
[Assuming table structure:(Mov_id pk,Mov_name,Cost)it should be some thing like this:
if Mov_id not in table_Movie
insert into ....
else update table_Movie set .... where... ]This is for single row.I want to do in bulk.
Please help ASAP as I am in urgent need..

解决方案

You can use XML input parameter and use OPENXML in SP.


这篇关于如何一次更新并插入多行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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