Changing a value in a column manually with SQL Server Management Studio - sql-server

I have a row in my table, and I want to change one of the values in a column. For example... I want to change the status in a particular row from "Development" to "Production".
In MySql Workbench there was an option to click the value and you could simply type in the value you wanted. Is there a similar method in Microsoft SQL Server without typing a SQL statement?

Right click on the table you want to edit and then choose Edit first 200 records.
In that table you can modify the values. It will be saved instantly.

Following up with the accepted answer, if you wanted to edit more rows than "Edit Top 200 Rows" gives you, you need to have the "Query Designer" selected in order to show the [SQL] button.
1) right click on the "New Query" button
2) select the "Query Designer" option
3) now your toolbar will look like this...
After you select the "Edit Top 200 Rows," you will see the SQL button (shown in yellow) that will show you the query where you can change the 200 to whatever you'd like.
I was having issues finding the "[SQL]" button, so hopefully the screenshot will help.

Related

How to re-run the query in the SQL Server Management Studio "Edit Top ### Rows" window

I am editing a table row in SSMS, and when the row committed, it appeared tan-colored instead of black with a red exclamation mark indicating that there was a problem attempting to get the data back after the row committed.
It says to re-run the query, but I don't know how to do that, other than to close the window and re-load it via the context menu:
The "Execute" button is grayed out on the "SQL Editor" toolbar, and F5 doesn't work either.
How do you re-load or re-fresh the data in situ?
Try going to the "Query Designer" menu and clicking "Execute SQL".
I've never known this until just now, but it seems that the "Edit Top 200 rows" area you're in has query-builder options (such as "Add Table" and "Add Group By"), and you can press ctrl + 3 to get the sql statement involved. I even changed the Select Top (200) statement to Select Top 2 and produced an order by statement and it still produced an editable viewer, which I confirmed registered the edit.
As you noted the Execute button is part of the SQL Editor tool bar. You need the Query Designer tool bar, once present you can hit the Execute SQL button (the ! point), I believe there are also two shortcut keys (Ctrl+R) and (Alt+X).

pgadmin 4, cannot find "edit data"

I read the Q/A "How to insert a row in postgreSQL pgAdmin?" from enter link description here
, but it's for pgAdmin 3.
I just installed postgreSQL 9.6.2 with pgAdmin 4, but could not find the option shown in pgAdmin 3, which you can click to have an excel-like window where you can add and update data in a table without using SQL language (as per #KarelG). Does anyone know whether it stills exist in postgreSQL 9.6.2 with pgAdmin 4? Thanks.
After editing the data, simple click on Save Data Changes (F6) icon.
You can select the table, use the right mouse button to select “View Data” and any of the subselections you choose.
You can add new rows in the resulting grid.
To save them in the database, use the “Save” icon with the image of a floppy disk:
The table needs to have a primary key to become editable in pgadmin so that the column names have a pencil icon next to them instead of a padlock.
You can right-click the table, then select View-Edit Data, and select Filtered Rows, Edit the rows and simply close on the X in the upper right. It will ask you if you want to SAVE.
I had some trouble finding this too, but found it eventually: Right-click the table, then select "View/Edit Data", and select "Filtered Rows", then enter the condition (format: field name = ). Now it will only be showing the row you want to find and edit, and you can double-click the value, change it, then click the save-icon button to save it.
I had the same trouble. Trying to find out some short keys, I found using F6 key pretty useful.
Query tool -> F5
It will run the current query in the query editor.
Query tool -> Edit some cells -> F6
It will save the current changes to the database.
Check the query history to confirm what happend exactly.

How to identify database in SQL Server Profiler?

In the SQL Server Profiler, I've added a filter for:
DatabaseName Like MyDatabase
I then log into the same server and run:
select * from MyDatabase
I don't see any entries in the Profiler. I remove the above filter and run the statement again. It shows up in the Profiler.
Any idea why it isn't working with the filter?
Also, is there a way to filter on three databases? In other words, I want to see execution against three databases.
On the Events Selection tab of the Trace Properties window, hit the "Column Filters..." button and click on DatabaseName. From here you can filter to your database(s). If you double click on the "Like" group after entering your first database name, it will add another blank spot to enter a new name.
When you start a new trace, click the Event Selection tab and then click the "Show All Columns" checkbox. Then, scroll the window until you see the column "Database Name", and check all of the checkboxes there.

Is it possible to modify the default SQL in query analyzer for 'edit top 200 rows'?

What if I want to edit the bottom 200 rows, or a custom query, is this possible?
You should be able to do the following:
Load the query window with the edit 200 rows
From the Query Designer Menu > Pane > SQL or use the SQL button from the Query Designer toolbar
Edit the query to the number of rows that you want or order by ID, etc
Execute the new query and the window will be refreshed.
When you click on "edit Top 200 rows", there is a button on the top right corner that says "SQL", when you click on that, you can write your custom query.
If you want the default value for the edit TOP n rows, you can go to "Tools->Options->SQL Server Object Explorer" and edit the 200 there.
I'm not sure about Query Analyzer, but in Management Studio you can right click and select Pane > SQL to view/edit the SQL query used

SQL Server Profiler - How to filter trace to only display events from one database?

How do I limit a SQL Server Profiler trace to a specific database? I can't see how to filter the trace to not see events for all databases on the instance I connect to.
Under Trace properties > Events Selection tab > select show all columns. Now under column filters, you should see the database name. Enter the database name for the Like section and you should see traces only for that database.
In SQL 2005, you first need to show the Database Name column in your trace. The easiest thing to do is to pick the Tuning template, which has that column added already.
Assuming you have the Tuning template selected, to filter:
Click the "Events Selection" tab
Click the "Column Filters" button
Check Show all Columns (Right Side Down)
Select "DatabaseName", click the plus next to Like in the right-hand pane, and type your database name.
I always save the trace to a table too so I can do LIKE queries on the trace data after the fact.
By experiment I was able to observe this:
When SQL Profiler 2005 or SQL Profiler 2000 is used with database residing in SQLServer 2000 - problem mentioned problem persists, but when SQL Profiler 2005 is used with SQLServer 2005 database, it works perfect!
In Summary, the issue seems to be prevalent in SQLServer 2000 & rectified in SQLServer 2005.
The solution for the issue when dealing with SQLServer 2000 is (as explained by wearejimbo)
Identify the DatabaseID of the database you want to filter by querying the sysdatabases table as below
SELECT *
FROM master..sysdatabases
WHERE name like '%your_db_name%' -- Remove this line to see all databases
ORDER BY dbid
Use the DatabaseID Filter (instead of DatabaseName) in the New Trace window of SQL Profiler 2000
In the Trace Properties go to the Event Selection tab. Then click on the Show All Columns radio button. After that click on the Column Filters button.
Now you can see the Database Name property and click on it. Expand the like box and insert your DB name and click ok and you can run the profiler now.
In the Trace properties, click the Events Selection tab at the top next to General. Then click Column Filters... at the bottom right. You can then select what to filter, such as TextData or DatabaseName.
Expand the Like node and enter your filter with the percentage % signs like %MyDatabaseName% or %TextDataToFilter%. Without the %% signs the filter will not work.
Also, make sure to check the checkbox Exclude rows that do not contain values' If you cannot find the field you are looking to filter such as DatabaseName go to the General tab and change your Template, blank one should contain all the fields.
Create a new template and check DBname. Use that template for your tracefile.

Resources