You are viewing limited content. For full access, please sign in.

Question

Question

Custom Query running stored procedure not inserting records in SQL table

asked on December 15, 2014

Hi,

We have a custom query that runs a stored procedure. The stored procedure uses a token to do a search on a database, and then it inserts it into a "Results" table. The first the stored procedure does, however, is to delete all previous records inside that table. The problem is that after the stored procedure runs from workflow, it only deletes the records, but it doesn't add the results found. When we test the stored procedure on Management Studio, it works perfectly. We have tested it in workflow using the "Test" button on the Custom Query and manually typing in a test value we know works, but it still won't insert any results into the Results Table. This is how the custom query window looks like:

 

This is the exact code we use to run the stored procedure from the Custom Query activity:

USE [CSC_LF_Lookup_DB]

DECLARE	@return_value int,
		@VendorId int

EXEC	@return_value = [dbo].[FindVendor]
		@LongVendorName = N'@VendorName',
		@VendorId = @VendorId OUTPUT

SELECT	@VendorId as N'@VendorId'

SELECT	'Return Value' = @return_value

So far, we know this:

- Stored procedure runs in workflow

- Stored procedure doesn't insert values found into table, despite using the same value in Management Studio to run that code and getting a result. 

 

Any ideas?

0 0

Answer

SELECTED ANSWER
replied on December 16, 2014

Hi Miruna,

Without the "N", the stored procedure still runs, but it won't write any results on the table.  You have, however, pointed me towards the answer. I have updated my script to look like this:

And now it works perfectly! Thank you very much for taking me on the correct direction

1 0

Replies

replied on December 15, 2014

What if you remove the "N'" in front of the parameter?

Is this using the ODBC driver?

0 0
SELECTED ANSWER
replied on December 16, 2014

Hi Miruna,

Without the "N", the stored procedure still runs, but it won't write any results on the table.  You have, however, pointed me towards the answer. I have updated my script to look like this:

And now it works perfectly! Thank you very much for taking me on the correct direction

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.