在SQL Server中更新查询 [英] Update Query in SQL Server

查看:146
本文介绍了在SQL Server中更新查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张表,其中包含大约2亿卢比的记录。该表还包含150多列。在这150多列中,我需要使用值更新几列。通过将列值作为输入传递,将从函数生成新值。在函数内部将有几行代码将根据提供的输入返回一个值。



现在我的问题是关于需要遵循的方法更新生产中具有良好性能的记录。



选项1:为每个列编写更新查询以便一次更新(如果我有10列,则更好)要更新,将写入10个单独的更新语句)?



选项2:在单个更新语句中,所有10列都会更新。



哪种方法更好,请提供您的意见。

先谢谢。

I have a table which contains around 2 crore plus records. The table contains 150+ columns as well. Among these 150+ columns i need to update few columns with a value. The new value will be generated from a function by passing the column value as input. Inside the function there will be few lines of code which will return a value based on the input supplied.

Now my question is regarding the approach that needs to be followed to update records with good performance in production.

Option 1: Is it better to write an update query for each column to update at a time( Means if I have 10 columns to update, 10 separate update statements will be written)?

Option 2: In a single update statement all the 10 columns are updated.

Which approach is better, Please give your inputs.
Thanks in Advance.

推荐答案

更好性能是在一次UPDATE调用中更新所有10个字段,并且从SQL命令执行速度应该比每个字段的每次单独更新快10倍。
The better performance is to update all 10 fields in one single UPDATE call, and from the SQL command execution speed should be almost 10 time faster then each individual update for each field.


这篇关于在SQL Server中更新查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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