在 SQL Server 中手动编辑选定的行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9552877/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Edit selected rows manually in SQL Server
提问by Cipher
I have a database in which some editing operations have to be done manually on some rows. I have the SQL Server Management Studio Express. In SSMS, to edit the rows, normally the option is:
我有一个数据库,其中一些编辑操作必须在某些行上手动完成。我有 SQL Server Management Studio Express。在 SSMS 中,要编辑行,通常选项是:
Select DB > Table > Right Click > Edit top 200 rows
Select DB > Table > Right Click > Edit top 200 rows
But, the problem here is that I only have to edit some selected rows. I am able to retrieve these selected rows by the following query:
但是,这里的问题是我只需要编辑一些选定的行。我可以通过以下查询检索这些选定的行:
/****** Script for SelectTopNRows command from SSMS ******/
SELECT *
FROM [test].[dbo].[Sheet1] WHERE Item1 IS NULL OR Item2 IS NULL
Now, I have to perform some edit operations (moving some data from some columns to others) which can't be performed with a query because of no single observable pattern for editting. So, the question remains, how can I get these rows in edit mode to do my task?
现在,我必须执行一些编辑操作(将一些数据从某些列移动到其他列),由于没有用于编辑的单一可观察模式,因此无法通过查询执行这些操作。所以,问题仍然存在,我怎样才能让这些行进入编辑模式来完成我的任务?
回答by Denis Valeev
Click edit rows on the table and then open the sql tab of that query and add your predicate there. And that's how you can edit filtered records.
单击表上的编辑行,然后打开该查询的 sql 选项卡并在那里添加您的谓词。这就是您可以编辑过滤记录的方式。
回答by PraveenVenu
As you said, go for
正如你所说,去
Select DB > Table > Right Click > Edit top 200 rows
Now the window opens with the top 200 query and the results editable.
现在窗口打开,其中包含前 200 个查询和可编辑的结果。
Now change the query to the one with your where clause and hit F5
现在将查询更改为带有 where 子句的查询并点击 F5
回答by Excelsior Simpatico
After you have your 200 rows displayed for editing, you can also click on the "SQL" icon which will now be available above the Object Explorer. This is another way to have the SQL displayed which you can now edit as needed in order to change the desired rows.
显示 200 行进行编辑后,您还可以单击“SQL”图标,该图标现在将位于对象资源管理器上方。这是显示 SQL 的另一种方式,您现在可以根据需要对其进行编辑以更改所需的行。