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!

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

March Community Office Hours Security Series Uncovered!

Hello Splunk Community! In March, Splunk Community Office Hours spotlighted our fabulous Splunk Threat ...

Stay Connected: Your Guide to April Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars in April. This post ...