DataGrip is not providing intellisense support - sql-server

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

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

Intellisense is not working in Visual Studio Code - mssql extension

I am using Visual Studio Code with the mssql extension.
I am expecting intellisense to help me with table names and column names.
But if I type
SELECT * FROM dbo.
and press Ctrl-Space then I am hoping to see a list of tables. But I don't see anything. I believe my expectation that this should work is correct. Does anybody know how to fix this?
I am thinking now that this was because I hadn't established a database connection. So I was getting Intellisense on keywords but not database tables or columns.
Another thing that's worth noting for anyone else that comes across this issue is that if you don't specify a database name when connecting(because you have multiple DBs under a single connection) - you will connect to 'master' and won't get any IntelliSense on the schema. I suspect this is because different Databases could have different Schemas.
If this is your situation and all your Schemas are the same I would suggest creating two connections; one with a DB name specified and one without. You could then get the IntelliSense on your named DB editor window and Copy and paste your code into your editor window with the 'master' connection obviously adding the "use..." at the top of the window.
Hopefully a nicer solution to this issue is created but in the meantime this is what gets me by.

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

Group tables by schema in SSMS

In Visual Studio's Server Explorer window there's a very nice feature that lets you see the DB objects grouped by schema:
It turns this object tree:
Data Connections -> MyServer -> Tables -> MyTable (MySchema)
Into this one:
Data Connections -> MyServer -> Schemas -> MySchema -> MyTable
I've been looking for this particular feature in SSMS but was unable to find it.
Does it exist?
If not, is there a plugin which would provide this feature?
Or perhaps is there a plugin which would help ease navigation in DBs which have lots of objects?
Please note I'm aware of SSMS object filters. It's better than nothing but not sufficient, as I'm often accessing objects from multiple schemas at once.
If you want a free tool, SSMS Schema Folders (GitHub repo) is your solution. It does the job beautifully.
I love the idea of grouping by schema.
SQL Treeo SSMS Addin is an inexpensive tool that allows you to create your own table structure in the Object Explorer.
You can try as follows in SSMS:
Tables > Filter > Filter Settings
There you are able to filter by schema...

Resources