SQL Conditional Alerts - sql

I am new to SQL and use Azure Data Studio for data analysis. I am trying to setup a conditional email/text alert when a column value is greater than a given value in my SQL database. I am confused how to go about this... would I use SMTP, Azure monitor, etc.?
I have looked into Azure monitor, but it seems that it is more commonly used for alerts regarding the performance of a database and not the values contained within the database.

It is possible to send an email message from SQL Server using the sp_send_dbmail system proc.
This is documented at Microsoft

Related

Identify relationships between multiple databases in SQL

I am working on migrating an application from one server to the other. According to the connection string of this application, it is touching different databases. Meaning a view query in DB1 will touch a table in DB2. So while migrating this application, I constant get to see chain of 'Database unavailable' errors and every time I see such error, I have to migrate that specific database.
I am wondering, since we have ER diagrams to know about relationships between tables in a database, is there any way in SQL server to know the relationships/linkages between different DATABASES in a server? Are there any tool that does this?
Depending on number of databases you have, here would be a somehow quick way you can find that out (number of required search = number of available databases in the server):
Use 'SQL Search' application of Red-get
(https://www.red-gate.com/dynamic/products/sql-development/sql-search/download)
and search for the other database names one after another by selecting
your database of interest. Select all objects.
If you have metadata oriented design (a Stored Procedure looping through the names of different other Stored Procedures / Functions from different databases which are stored in a table as metadata and executing them with a wrapper Stored Procesure), then you will have make use of SQL Locator software (http://www.sqllocator.com/Downloads.html) to search for database names in SQL Table values.
Both of the above software are free.
You need to have SSMS (SQL Server Management Studio) installed to be able to use this application. After installation, ‘SQL Search’ will be directly available in your SSMS as an add-on.
SQL Locator can be directly used by providing the SQL Server name and your SQL Server credential.
Note:- The above steps will help you find out the referenced databases from a certain database within the same SQL Server. If you need to find out databases from Linked Server (I do not believe your question is asking that anyways), then you will have to smartly utilize the same above tools to find the external server reference by searching the external server name.

How to run a T-SQL query daily on an Azure database

I am trying to migrate a database from a sql server into Azure. This database have 2 rather simple TSQL script that inserts data. Since the SQL Agent does not exist on Azure, I am trying to find an alternative.
I see the Automation thing, but it seems really complex for something as simple as running SQL scripts. Is there any better or at least easier way to do this ?
I was under the impression that there was a scheduller for that for I can't find it.
Thanks
There are several ways to run a scheduled Task/job on the azure sql database for your use case -
If you are comfortable using the existing on-premise sql sever agent you can connect to your azure sql db(using linked servers) and execute jobs the same way we used to on on-premise sql server.
Use Automation Account/Runbooks to create sql jobs. If you see marketplace you can find several examples on azure sql db(backup,restore,indexing jobs..). I guess you already tried it and does not seem a feasible solution to you.
Another not very famous way could be to use the webjobs(under app service web app) to schedule tasks(can use powershell scripts here). The disadvantage of this is you cannot change anything once you create a webjob
As #jayendran suggested Azure functions is definitely an option to achieve this use case.
If some how out of these if you do not have options to work with the sql directly , there is also "Scheduler Job Collection" available in azure to schedule invocation of HTTP endpoints, and the sql operation could be abstracted/implemented in that endpoint. This would be only useful for less heavy sql operations else if the operation takes longer chances are it might time out.
You can use Azure Functions to Run the T-SQL Queries for Schedule use Timely Trigger.
You can use Microsoft Flow (https://flow.microsoft.com) in order to create a programmed flow with an SQL Server connector. Then in the connector you set the SQL Azure server, database name, username and password.
SQL Server connector
There are many options but the ones that you can use to run a T-SQL query daily are these:
SQL Connector options
Execute a SQL Query
Execute stored procedure
You can also edit your connection info in Data --> Connections menu.

User Specific Reporting with SQL Azure Reporting Services

Is there any solution to user-specific reporting with Azure SSRS? I have an Azure database with a user table and only want my reports to query data pertaining to the user.
Any tips/alternatives would be greatly appreciated.
Windows Azure SSRS supports the User!UserID property so you can use it for user-specific reporting and that would be the easiest way to get it done.
Also about filtering SQL query using the user_name() may work or not. If you use ‘Stored Credential’ option for the RS data source, the same credential will be shared by multiple users. In that case, you can’t rely on user_name(). If you use ‘Prompt’, and if each user needs to supply a unique credential for himself or herself, then you can use user_name().
Does Azure SSRS support the User!UserID property? If not, you should be able to filter in the SQL query using the user_name() function.
these guys actually implemented user specific SQL queries in their report. check it out:
http://www.upsizing.co.uk/Art68_ReportViewerControlAndSQLAzure.aspx

Does Microsoft Sql Server 2012 Data Quality Services support Oracle?

Does anyone know if Data Quality Services in Sql Server 2012 can be used against Oracle databases to improve their quality? I've had a look around the Sql Server site and can't determine if it can or not.
Thanks,
Steve.
There are two ways to use Data Quality Services over Oracle DBs.
Via the DQS SSIS cleansing component - you can use this as part of an SSIS flow that retrieves the data from the Oracle DB, cleans it within the SSIS flow using the DQS component, and then sends it back to the Oracle DB.
Via the use of the Linked Server functionality of SQL Server. See http://social.technet.microsoft.com/wiki/contents/articles/7540.accessing-your-data-on-remote-servers-for-dqs-operations-by-linking-servers.aspx for more information on how to do this.

Access remote Oracle from SQL Server in query only? (Crystal Reports command)

We have a peculiar challenge with overly-strict use restrictions, and I'm trying to find a way to accomplish it.
We have data in two locations, on different platforms. We are extracting data from application tables, and we aren't allowed to create our own views/procs/etc.
Is there a way to run a query into a remote Oracle DB from within an SQL Server query?
To further complicate issues, we have to make it run through a Crystal Reports database command.
We have ODBC connections defined at the BOXI platform (using Oracle ODBC for the Oracle connection).
I am hoping to use the SQL WITH clause to build in-memory views (for lack of a better term) to:
Initially extract some circuit IDs from the local SQL Server system,
Extract ticket numbers based on those circuit IDs, from the remote Oracle system,
Extract the core of our data from the SQL Server system, joined with the ticket data and return that to Crystal as a result dataset.
If we had our own space, this would be trivial.
BOXI doesn't let us do multiple-server universes.
You would need to some way to write and store connection strings, but it doesn't sound like you're able to do this.
If you can't make ANY changes to either source system, you might try creating an MS Access DB and using linked tables to bring in all the information you need and have your Crystal Report run from that. You would then only need to make sure that the machine you're running this on has the ODBC drivers to be able to connect, which are simple enough to configure.