Can we connect Cosmos DB to SSRS? - reporting-services

I have to use Azure Cosmos DB in SSRS reports. I have used ODBC connector. I am able to fetch data using simple select query. But not able call stored procedure or function in SSRS reports. Is it possible to call Cosmos DB stored procedure in SSRS like?

Cosmos DB not being a relational database and its procedures being written in Javascript are irrelevant factoids in the context of the question.
There are ways you could directly and indirectly query data in Cosmos via a stored procedure in SQL Server which in turn could be used as the datasource for SSRS reports.
1) Write a Python script that connects to Cosmos DB, queries the data you're looking for into JSON documents, and writes these to a file https://learn.microsoft.com/en-us/azure/cosmos-db/sql-api-python-samples.
If this query in Cosmos requires scanning documents in multiple partitions you can enable cross partition queries. "To run a query across partitions, set EnableCrossPartitionQuery to true (or x-ms-documentdb-query-enablecrosspartition in the REST API)"
https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-query-container
2) Create a stored procedure in SQL Server. Use xp_cmdshell in the SQL Server stored procedure to execute the Python script in step 1. Or you can create an agent job in SQL Server with a powershell step -- and the stored procedure can execute this job.
https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/xp-cmdshell-transact-sql?view=sql-server-ver15
Run Python Script from MSSQL
Use BULK INSERT in the procedure to insert the JSON data in the file into a table in SQL Server -- then use the T-SQL OPENJSON function to parse the JSON into columnar form.
https://learn.microsoft.com/en-us/sql/t-sql/functions/openjson-transact-sql?view=sql-server-ver15
3) Add the stored procedure as the datasource for an SSRS report.
If you're using the MongoAPI you could also directly query Cosmos using Polybase in SQL Server 2019.
https://learn.microsoft.com/en-us/sql/relational-databases/polybase/polybase-configure-mongodb?view=sql-server-ver15

Connect Cosmos DB to SQL using Cosmos DB ODBC Connector.
https://learn.microsoft.com/en-us/azure/cosmos-db/odbc-driver#connect
Create a stored procedure to call Cosmos object using OPENQUERY command like below.
Select * FROM OPENQUERY( select * from [CosmosDB].[Table] )
https://www.sqlshack.com/link-an-azure-cosmos-db-into-a-sql-server-stored-procedure/
Once having the stored procedure, it should be easy to use it in SSRS.

Cosmos DB is not a relational database, and its stored procedures are not the same thing as a SQL Server stored procedure (and there is no SQL in a Cosmos DB stored procedure; only JavaScript, executing against the documents within a specific partition).
You cannot call a Cosmos DB stored procedure from SSRS. You can only invoke a Cosmos DB stored proc via SDK (or REST API) call.

Related

MySQL Stored Procedure in SSIS destination

Is it possible to use MySQL stored procedure in DataFlow task destination?
While SQLServer is the source, MySQL DB is the destination, and I would like to use stored procedure to normalize the data. Currently the process uses ADO NET Destination with ADO.NET connection manager to insert data into a single table and it works.
Well, Yes you can use it. But take care about Connection of MySQL and Parameters you passed to Stored Procedure.
Current System and use of StoredProcedure both will work for same.
You can't use a stored procedure as a destination, but you can use a staging table as a destination and then call a stored procedure that normalizes your data as it sends it to the destination tables.

SSIS ETL execute MySQL Stored procedure on Destination Server

I am working on an SSIS ETL and I wanna know if there is a possibility to execute a MySQL Stored Procedure.
Here is what I want to do : From an SQL Server Database, I want to get Information by an ETL (SSIS) and send them to a MySQL Database (by a stored procedure)
Here is what I have done so far : I get my data from SQL Server Database and tranform them.
Here where I am stuck : I don't know how to execute an existing stored procedure on the MySQL Server Database (my destination)
Here is my ETL (DATA FLOW) diagram :
I also add an OLEDB provider on the server and add my destination source (MySQL Database) but I don't know what I need to do in my ETL to execute the stored procedure.
I can provide more information if necessary.
Thanks in advance
I am not sure if you mean that you want to execute a stored procedure by passing in every row in memory in SSIS that enters through your multicast. If that is the case, that may be possible with SSIS, but I have never done it.
why not just send the rows to two separate tables in MySQL from the multicast, then go back to the control flow tab and add two execute sql tasks, one for each stored procedure. Change each stored procedure to run on the tables instead of individual rows.
You would probably get a performance boost as well from switching to a set based operation instead of row by row.

How to call a View from a Stored Procedure in Server 2008?

Im in the process of migrating an Access DB to Sql Server 2008 and right now Im converting these Access macros to store procedures. Most of the macos are calling queries so Ill need to convert the queries into views and then have the stored procedure call the views. What is the syntax to call the view?
Same syntax as selecting data from a table:
SELECT *
FROM view

Calling MS Access Stored Queries with Parameters using DAAB v5.0

I wanted to find out if it is possible to call MS Access Stored Queries with parameters using DAAB.
I am using the Northwind sample database to test this scenario I have created the following Stored Query with parameter in MS Access:
PARAMETERS FirstName Text ( 255 );
SELECT Employees.ID
FROM Employees
WHERE (((Employees.[First Name])=[#FirstName]));
This query is stored with name: GetEmployeeIDByName
I have created a wrapper over the DAAB to allow access to various databases like SQL, Oracle, any OLEDB and and ODBC database.
Below is the sample code for my test:
Database db = new GenericDatabase("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\Database\Access\Northwind 20071.accdb",OleDbFactory.Instance);
DbCommand cmd = db.GetStoredProcedure("GetEmployeeIDByName");
db.AddInParameter(cmd,"#FirstName",DbType.String,40);
object employeeID = db.ExecuteScalar();
I get an error Invalid Operation. I am not sure if I am calling the stored Queries correctly as I am able to call Stored Queries that do not have any parameter without any errors.
I was able to resolve the issue. The issue was with the Northwind sample database. I then imported Northwind database from SQL Server into MS Access and also created the stored queries in MS Access. Here is the detailed discussion that I had with the Enterprise Library DAAB's team: entlib.codeplex.com/Thread/View.aspx?ThreadId=223653 Hope it helps. Access does not care about the # character you can call the parameter with or without the # character.

BizTalk 2009 Community ODBC Adapter - Generating Schemas from MySQL Stored Procedure

I am am currently trying out the Community ODBC Adapter (from TwoConnect) to call stored procedures on a MySQL database.
I have been able to use the MySQL ODBC driver to connect to the database, but when generating the schemas for a stored procedure with input parameters I am getting the following error:
Incorrect Number of arguments for Procedure addupdate_product; expected 7, got 0
This error occurs following the press of the Generate button, with the Query:
addupdate_product()
How to correct the syntax?
SHOW CREATE PROCEDURE addupdate_product; doesn't tell you which parameters to provide, or are they not coming through?
I have now figured out how to use the ODBC Adpater with a MySQL stored procedure that has parameters.
The key to this is not selecting the stored procedure option and instead using the SQL Script option.
Full details can be found here :
http://geekswithblogs.net/StuartBrierley/archive/2010/06/09/biztalk-2009---the-community-odbc-adapter-schema-generation-with.aspx