Archive

Can DB Connect run stored procedures

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

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

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

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

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

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.

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

Contributor

Hi,

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

Splunk Employee
Splunk Employee

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

0 Karma

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

State of Splunk Careers

Access the Splunk Careers Report to see real data that shows how Splunk mastery increases your value and job satisfaction.

Find out what your skills are worth!