Edit selected rows manually in SQL Server

2020-05-22 00:13发布

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:

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?

3条回答
萌系小妹纸
2楼-- · 2020-05-22 00:34

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.

查看更多
做个烂人
3楼-- · 2020-05-22 00:37

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.

enter image description here

查看更多
在下西门庆
4楼-- · 2020-05-22 00:40

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.

Now change the query to the one with your where clause and hit F5

查看更多
登录 后发表回答