如何在SQL Server Management Studio中编辑多个行/数据条目 [英] How to edit MULTIPLE rows/data entries in SQL Server Management Studio

查看:664
本文介绍了如何在SQL Server Management Studio中编辑多个行/数据条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用SQL Server Management Studio更新/编辑数据库中的多行。我知道您可以使用提供的解决方案编辑一个条目此处 此处,使用Edit Top(200)函数。但是我要编辑> 100个条目,因此这不是一个合适的解决方案。我正在使用SSMS 2012。

I want to update/edit multiple rows in a database using SQL Server Management Studio. I know you can edit one entry using solutions provided here, here or here using Edit Top(200) function. But I want to edit >100 entries so this is not an adequate solution. I am using SSMS 2012.

编辑:

作为简化示例,我们可以看看以下情况:
我有一个民族名称和身高数据库。但是许多高度是错误的或未更新。所以我想更新他们的身高。此更新包括很多人,并且使用我链接的解决方案逐个更新也是很麻烦的。我必须更新存储在Excel文件中的值。

As an simplified example we can look at the following situation: I have a database of peoples names and their height. But many of the heights are wrong or not updated. So I want to update their heights. This update includes a lot of people and it is tedious to update one by one using the solution I linked too. I have to updated values stored in an Excel file.

我不确定如何解决此问题,但正在寻找一种方法来复制粘贴更新后的值

I am not sure of how to attack this problem, but is seeking a way that I can copy paste the updated values directly into the tables or do this indirectly using some sql statement.

推荐答案

如果选择 编辑前200名,则直接将其插入表中行 ,您可以先修改查询以返回250行。

If you select Edit Top 200 Rows first, you can then modify your query to return 250 rows.

为此,您需要点击 显示SQL窗格 按钮,位于左上角, 新查询 按钮正下方。

In order to do this you need to click on Show SQL Pane button, in the top left corner, just below the New Query button.

在查询窗口中,将 200 更改为 250 ,然后按Ctrl + R刷新。

In your query window change 200 to 250 and hit Ctrl + R to refresh.

但是,如果您确实需要更新此行数,则可能应该使用原始SQL并编写正确的UPDATE语句。

However, if you really need to update this number of rows, you should probably use raw SQL and write proper UPDATE statements.

编辑:

在您描述的情况下,我通常会创建单个 UPDATE 语句,然后复制全部内容以在SQL中执行:

In the situation you described, I normally create individual UPDATE statements within Excel and then copy the whole lot to execute in SQL:

这篇关于如何在SQL Server Management Studio中编辑多个行/数据条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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