pgAdmin4: How do I edit the SELECT query generated by "View/Edit Data > All Rows"? - pgadmin-4

I recently migrated from MariaDB and there was a useful shortcut to construct a query in MySQL Workbench - you would right click the table and select "Select rows - Limit 1000". pgAdmin4 has an identical shortcut however I cannot edit the query in the Query Editor after the query has run. The query is grayed out/disabled.
Is there a way to "unlock" the input and make it editable, so I can adjust the query and re-run it?
Any help would be appreciated. Thanks!

The View/Edit Data page is just a limited version of the Query Tool, according to pgAdmin's documentation1:
The Query Tool and View/Edit Data tools are actually different operating modes of the same tool. Some controls will be disabled in either mode. Please see The Query Tool Toolbar for a description of the available controls.
So use Query Tool (accessible from the same context menu) instead of using View/Edit Data. You can edit the query there.

You can use Scripts > SELECT Script which opens the Query Tool with a pre-filled script that does the same as View/Edit Data > All Rows

Related

how to select a bunch of objects automatically in ssma(SQL Server Migration Assistant)

I'm using ssma to migrate from oracle to SQL Server with about 1000 tables.
And during the migration, about 100 tables went wrong (because of wrong type mapping) and I want to rerun only those tables.
Are there any way to select them automatically(by script or even some third-party tools) rather than click them one by one?
Answering my own question..
Turns out ssma has a built in function called "Advanced Object Selection" in the right click menu.
Advanced Object Selection
And then you can input tables(or other object names) in the "Set Selection".
Set Selection

DataGrip is not providing intellisense support

DataGrip from JetBrains is not providing Intellisense for Cross Database queries.
use mydb;
select * from otherdb.dbo.
using MSSQL
Leaving it for who seems to be struggling with this
1) while creating connection create without selecting DB.
2) In DB tree select click more Schemas and select DBs you want for cross querying.
3) Right click on those DBs and select synchronize
now cross DB should be working.
I came across this question in search of a solution to troubleshooting intellisense in DataGrip. The accepted answer didn't go quite far enough for my use case, see below for my solution:
A similar issue was posted to IntelliJ's community forms here.
This answer relates to DataGrip 2017.1.5 (is likely applicable to other versions as well):
After creating the initial connection to your server, open the Database tool window using:
(ALT + F1) or
(View -> Tool Windows -> Database).
Listed beneath your server connection you will see a "Schemas..." item, double click it. This will expand into a list of all DB schemas you have access to on that server.
Select the schemas you are interested in, and additionally expand each DB schema to select all child schemas for that DB.
Click the refresh button in the schema selection window to synchronize your settings (two arrows pointing at each other in a circle).
Image of Database Toolbar with DB/Schema selection

sql server profiler: How to know which db is being hit using sql server profiler

I have 2 application, connected to 2 different databases on one instance.
I am trying to trace some functionality using SQL Server Profiler(Standard Template) but difficult to understand which database is being hit by one application just by looking into the trace.
Kindly suggest how to know the dbname being hit by one application.
One option is to filter by each database name.
Under Trace properties > Events Selection tab > select Show all columns.
You should see the database name under column filters.
Enter the database name for the Like section and you should see traces only for that database.
You can also read more about this here
Use standard template (Default)
And you should see it.

SSMS - Generate Scripts - Data Only doesn't work with views?

I am trying to generate a data only script for a view using SSMS Generate Scripts feature. However, even though I select Data Only, it still only generates the view definition and not the data generated by the view. Is there something else I need to do?
I'm using SSMS for SQL Server 2014.
I know this is old, but I will answer it for other people who stumble on it.
Generate Scripts -> Data Only is bugged for views.
The easiest option without searching for other stored procedures or external tools is to copy the view contents into a table. Generate Scripts -> Data Only works fine with tables.
For example,
SELECT *
INTO NEWTABLE
FROM dbo.Component
Then you can do Generate Scripts on the NEWTABLE and select Data Only in Advanced and it will work.
You can then delete the NEWTABLE.
Given that Generate Scripts still doesn't appear to work for view data as of SSMS v17.9.1, an alternative depending on your needs might be to use the SQL Server Import and Export Wizard. You can read data from a view and write it to a table, across different databases and servers without resorting to a linked server.
SSMS is still poor at this, VS has been able to do this for a while
Use menu VIEW->SQL SERVER OBJECT EXPLORER
Create a new server
Navigate down to your table or view , right click -> View Data
use the filter to limit the dataset to what you are interested in
Then use the SCRIPT command (also available on context menu)
This works for views and tables.
Not super easy, but ill give it A-. Way better than other hacks that used to be available (including SSMS.ExportData which is not great)
hope that helps someone. I just had to export some rows and had to re-remember how to do this.
hope it helps someone...
greg

SQL Server Management Studio console window

I'd like to have a console window inside SSMS where I can run quickly a query to see what columns are in a specific table or test a query before writing it into a script and such things.
There are some addons for Visual Studio that provide cmd or powershell consoles where one can run commands. That's what I need in SSMS for SQL.
It'd be nice if that console would understand sql directly but I'd also be glad to have a powershell window embedded in SSMS if there's no other solution.
One trick that I like to use the default keyboard shortcut of Alt+F1 for sp_help. If you highlight a table name in a query window and hit that shortcut, it'll run sp_help with the table name as a parameter. This will give you all sorts of information on the table (columns, indexes, constraints).

Resources