Editing Only Certain Columns with Data Sorted / Ordered from a SELECT Query in MSSMS

Dean Everhart 1,541 Reputation points
2023-02-22T10:18:31.72+00:00

In MSSMS a Select query that selects only certain columns in a certain order and orders data displays data only. It does not allow editing of the values in the columns.

How do I create a query that selects only certain columns in a certain order and orders the data, that will allow me to edit the values in the columns?

Displays Data Only:

Select Field1, Field7, Field17
FROM TableName
ORDER BY Field7 ASC;

Second Question:

If MSSMS is not the best way to edit data in this way, what is?

SQL Server | Other
{count} votes

Accepted answer
  1. LiHongMSFT-4306 31,566 Reputation points
    2023-02-23T07:31:48.22+00:00

    Hi @Dean Everhart

    Did you have any chance to check Viorel's solution?

    Step1: Right click the table and select 'Edit Top 200 Rows'.

    User's image

    Step2: Click SQL button in the toolbar to show SQL pane.

    User's image

    Step3: Modify the query code and then click the 'Execute SQL' button User's image

    Step4: It'll now allow you to view and edit the display data.

    Second Question: If MSSMS is not the best way to edit data in this way, what is?

    You might have a try on Visual Studio. I'm not an expert on VS, but I find this thread which might help.

    Best regards,

    Cosmog Hong


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Olaf Helper 47,436 Reputation points
    2023-02-22T10:46:19.5366667+00:00

    SSMS = "SQL Server Management Studio" is a tool to manage SQL Server(s), not to edit data.

    The "Edit" option is a mini-tool with less functionality.

    And when you don't select the primary key, then you can not edit data, because SSMS don't know/identify which data to update.


  2. Guoxiong 8,206 Reputation points
    2023-02-22T16:28:20.91+00:00

    You can use the UPDATE statement to edit data. But you need to use the WHERE clause to specify the search condition (with the primary key or the unique constraint column) for the rows you want to edit. For example, if you want to edit a person's address in the table Address in the Microsoft sample database AdventureWorks2019, you need to know which address you want to edit. That means the value of the column AddressID which is the primary key column. Here is the code example:

    USE [AdventureWorks2019];
    GO
    UPDATE [Person].[Address]
    SET [AddressLine2] = 'Apt. 101'
    WHERE [AddressID] = 1;
    GO
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.