我想使用SQL Server Management Studio更新/编辑数据库中的多行。 我知道你可以使用这里提供的解决方案编辑一个条目, 在这里或这里使用编辑顶部(200)功能。 但是我想编辑> 100个条目,所以这不是一个适当的解决方案。 我正在使用SSMS 2012。
编辑:
作为一个简单的例子,我们可以看看以下情况:我有一个人名和他们的身高的数据库。 但许多高度是错误的或没有更新。 所以我想更新他们的高度。 此更新包含了很多人,使用我链接的解决方案逐一更新也很乏味。 我必须更新存储在Excel文件中的值。
我不知道如何解决这个问题,但正在寻找一种方法,可以将更新后的值直接粘贴到表中,或者使用某些sql语句间接执行此操作。
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.
EDIT:
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行。
为此,您需要单击左上角的“ 显示SQL窗格”按钮,位于“ 新建查询”按钮的正下方。
在您的查询窗口中将200更改为250,然后按Ctrl + R进行刷新。
但是,如果您确实需要更新此行数,则应该使用原始SQL并编写适当的UPDATE语句。
编辑:
在你描述的情况下,我通常在Excel中创建单独的UPDATE语句,然后将整个文件复制到SQL中执行:
If you select Edit Top 200 Rows first, you can then modify your query to return 250 rows.
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.
In your query window change 200 to 250 and hit Ctrl + R to refresh.
However, if you really need to update this number of rows, you should probably use raw SQL and write proper UPDATE statements.
EDIT:
In the situation you described, I normally create individual UPDATE statements within Excel and then copy the whole lot to execute in SQL:
更多推荐
发布评论