Automatically change database connection when creating new queries in SQL Management Studio - application-settings

In SQL Management Studio, you can query a database table by right clicking it in the object explorer and selecting 'Select XX Rows'. A window opens showing the query and results. The query includes the database and scheme names. This action does not affect the selected database connection in the toolbar's dropdown list.
I use this as a starting point for manually writing queries, and it's quicker to just query the tables. So I regularly change the current database connection to the database I just created the query for.
Is there a way to make the database connection in the toolbar's dropdown list automatically change to the database where you start a query in the object explorer?

This is solved since the release of SSMS 2016.

Related

what version of mysql are datasources using?

I have a calculated table that uses a join statement SQL query as its data source. good. Works fine.
But then I'm trying to add in the use of :Parameters and my attempts to create a default if it equals null are not working.
I tried this (In the onLoad client script):
if (app.datasources.Relations.query.parameters.x== null){
console.log("No xfound,using >");
app.datasources.Relations.query.parameters.x= ">";}
It works, but not on the initial load (it appears to apply AFTER the first load).
So I decided to try and bake it into the sql statement that makes the table like this, but all three of these iterations failed with "check your version of mysql" errors.
AND b.CSI_Code REGEXP select if(:x= null, "<",:x)
AND b.CSI_Code REGEXP select if(:x== null, "<",:x)
AND b.CSI_Code REGEXP select if(:x=== null, "<",:x)
I've got a workaround going where I set my parameters to the APP onload rather than the datasource onload,but ultimately I think it would be cleaner if I could get the SQL if nul set to default (">") part working.
If you have access to the Google Cloud Platform where your database is hosted, it lists the database version in the instance information (see picture). Per the FAQ, the options are currently MySQL 5.5, 5.6, or 5.7. If you click into the instance, and go to the Databases tab, each app has its own database with a name like "Wc7cVzeGEvbPjxj4". To confirm which database your app uses, the name should be listed in your Google App Maker app under (Your app in the developer GUI) > Settings Cog Icon > Database > Database Key.

Seeing What is Running on a Progress Open Edge Database

I am trying to resolve some connectivity issues between Business Objects and a Progress Open Edge database.
I am trying to find a system table (or tables) that can tell me what is running on the progress open edge database. I only have ODBC access to it.
Special bonus points if the running sql can be returned!
Thanks in advance....
It sounds like you want the "client statement cache".
This is available in 10.1C and higher. Once enabled for a session it will track the database access statements (SQL queries for SQL connections or 4gl stack trace for 4gl connections) as they occur. Is does not keep a history -- only the most recent statement is available.
I am a 4GL guy so you will have to excuse my SQL ineptitude but you can use SQL connections to fiddle with system tables.
The _Connect VST is what you are looking for. For best results use the _Connect-Id key which is "off by one" from the Usr# (Id fields on VST tables are indexed, no other fields are).
If you have access to the server, you can enable the client statement cache via PROMON. Select the "R&D" menu, then option 1, then option 18. Choose "1-Single" for SQL connections.
If you want to code it with SQL you need to muck about with the _Connect. _connect-cachingType and _Connect._connect-cacheinfo[1] fields.
_connect-cachingType = 1 will give you your most recent SQL statement (or 4gl statement if it is a 4gl connection)
_connect-cacheinfo is an array. element 1 is the only element with anything in it for SQL connection. (4gl connections may have a procedure stack trace...)
OE Databases have what is termed a "Statement Cache."
There's a KB on the technology here, and a discussion on accessing the cache information via the database's VST tables here.

SQL query using 2 different database engines

I need to use the results from an Oracle query in a SQLServer query within ASP.NET. Can I do this without exporting the Oracle query results to a temp file, e.g. csv, and creating a new table in SQLServer using the csv file? Thanks!
There are probably several different ways to do this, including connecting the SQL Server to the Oracle server using Linked servers,
But if that's not possible for some reason, or if you need to use the Oracle resultset as well as the SQL Server resultset in your asp.net page, you can fill a DataSet with the Oracle query results, and send a DataTable as a table valued parameter to a stored procedure in the SQL Server.
Look at this page in MSDN, explaining how to use table valued parameters in sql server.
You can also look here for a step by step instruction on how to create and use table valued parameters in c#.

Trace the Cause for update of Sql Table

I have a table Product which have Quantity column, This table get updated thru .net application using Stored procedure based on flag variable. Now im having problem reported from user that even though the flag variable is not set table is getting updated with new values.
Now i need to isolated the cause for the issue.How will i check which update and through which application this table is getting modified. I have no idea about it.
What is the best approach to resolve this issue?
Assuming you are using SQL Server:
You can monitor calls to SQL Server using SQL Server Profiler. You can setup a filter to monitor queries affecting the Product table. The log will show what the query looked like, when the query was executed, the database user executing the query, the name of the application (if that is specified in the connection string) and a bunch of other things.

Deleting Database in Linq

In normal condition, I can add schemas in the dbml file to empty database with code below.
But now when I run this code, I take the error "Cannot drop database "test" because it is currently in use." How can I do it?
Dim db As New UI_Class.UIData
If db.DatabaseExists Then
db.DeleteDatabase()
End If
db.CreateDatabase()
It might happen as your SQL Server Management Studio (SSMS) must be holding it.
Most likely something is connected to the db.
Common causes are:
Some other tool connected
Trying to delete the database you connected to.
Another user connected to the db.

Resources