Monitoring Splunk

Can DB Connect run stored procedures

adityapavan18
Contributor

Can you anyone help me if its possible to run stored procedures from DBCOnnect?
I didnt find any documentation on this?

If its possible can anyone give a sample/example on how to run??

Tags (1)
1 Solution

sroback_splunk
Splunk Employee
Splunk Employee

Hi. Splunk DB Connect currently does not support stored procedures. This feature might be available in future releases, depending on demand.

View solution in original post

asuprun
New Member

I don't understand what is the issue with stored procedures? When you do it like "EXEC dbo.StoredProcedure" it's not even a parameterized stored procedure call! It is sent to a SQL Server as a simply query. Why DB Connect even bothered about the content of the query? Send it to the server as is and get a result. What could be easier? Do you have parse it or what? It's so confusing.

0 Karma

sh254087
Communicator

It was not supporting earlier and is now included in Splunk 7 and above. I tried this and this just worked fine for me -

| dbxquery connection="connection_name" query="EXEC [DatabaseName].[user].StoredProcedureName"

ex: | dbxquery connection="ConOne" query="EXEC [MyDB].[dbo].sp_Merge_Tables_AB" - where ConOne is the connection name, MyDB is the Database instance name, dbo is the user and sp_MergeTables_AB is the Stored Procedure that I have written which is intended to merge two tables.

0 Karma

John_L
New Member

Had a similar problem (MSSQL Server) trying to setup an Input which executed xp_readerrorlog. If you try:

EXEC sys.xp_readerrorlog 0;

You will receive an error that dbxquery does not support stored procedures. However, on a lark I tried:

EXEC('sys.xp_readerrorlog 0');

And this worked. Apparently, we can execute TSQL strings; so, all you have to do is wrap your stored procedure call in an EXECUTE command which executes a string as an SQL command.

0 Karma

joao_amorim
Communicator

Ok but idk cause I don't has that kind of error since I execute my SP's like you said the first time, EXEC user.sp_name
And if you need to pass variables to them it's EXEC user.sp_name @VARIABLE = value

Try that, it could be your solution.

joao_amorim
Communicator

I'm running two SP's almost for an year in Splunk DB Connect v1.

I also have two Data Inputs running daily (which are calling those SP's from a SQL DB) to populate two different indexes.

And I never had problems. How is this possible? Since it's not supported?

0 Karma

davidpaper
Contributor

Hi,

There is a workaround to be able to query SPs. See https://answers.splunk.com/answering/386947/view.html for more info.

gblock_splunk
Splunk Employee
Splunk Employee

SQL Server also supports user defined functions: https://msdn.microsoft.com/en-us/library/ms191320.aspx

0 Karma

sroback_splunk
Splunk Employee
Splunk Employee

Hi. Splunk DB Connect currently does not support stored procedures. This feature might be available in future releases, depending on demand.

Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...