We deleted some stored procedures related to Query notification service since we are not using them anymore. After deleting the procs we are seeing the error log getting filled with messages like below.
How do we stop such errors.
The activated proc '[dbo].[SqlQueryNotificationStoredProcedure-1c5b775e-e036-4181-8336-ba86d97d763d]' running on queue 'DATABASE.dbo.SqlQueryNotificationService-1c5b775e-e036-4181-8336-ba86d97d763d' output the following: 'Could not find stored procedure 'dbo.SqlQueryNotificationStoredProcedure-1c5b775e-e036-4181-8336-ba86d97d763d'.'
Try this. Run to get the name of the queue
select * from sys.service_queues
Then run
DROP QUEUE queueName
Related
I have a stored procedure that I execute through SSIS using an execute sql task. It appears to work on SISS, but when I look at the database the record is not created. The connection is for the correct database. The PROBLEM.
I have put a breakpoint ON and checked all the variables getting fed IN AND THEN ran it manually IN SQL SERVER management.
The SP work perfectly in SSMS with the same input parameters, but when executed through SSIS, it does not create the records required and does not give any error out.
In the SP I have a try catch to put any erorrs in the stored procedure when it erorr out to a table, but there is no entry for the SSIS run. According to the Error table for the SP and SSIS it looks like it executed successfully. When I go to see if the record it is not created. I cannot see the problem. Is there something I can put into the stored procedure to debug this problem or anything further I can do in SSIS to work this out ?
It has been 3 hours on this problem so looking for a fresh perspective to work out what is happening.
The SSIS package definitely points to the correct database and stored procedure.
From the watch window it appears to be giving all the parameters the correct values and does not error in SSIS.
Worked it out with sql profiler . In the Target database there is sequence that is incremented each time a new record needs to be created . When I deleted the record to rerun it it created it with a different ID number , I was expecting it to be created with the same ID number.
Thanks Billinkc !
I have created a SQL stored procedure that produces the expected results when I call it from SQL Management Studio, it has one output parameter which is a message that tells me where the proc failed, if it fails. Here is the top part of the proc
CREATE PROCEDURE [dbo].[uspProgramUpdate]
#EmailFailMessage VARCHAR(100) OUTPUT
At the bottom of my stored procedure is where I set the value of the variable:
BEGIN CATCH
ROLLBACK TRAN [CoS1]
RAISERROR ('***An error occurred during processing, all transactions have been rolled back. Correct the error and restart this process.***', 16, 1)
SET #EmailFailMessage = '***An error occurred during processing, all transactions have been rolled back. Correct the error and restart this process.***'
END CATCH
What I am trying to do (that I can't figure out) is how to capture the text of EmailFailMessage so I can use that text in an email within SSIS.
I have created an Execute SQL Task in SSIS which executes the stored procedure successfully on the SQL server. I have successfully captured the RAISERROR event and I can see that in the output window within Visual Studio window when I run the SSIS package:
Error: 0xC002F210 at Execute SQL - run uspProgramUpdate, Execute SQL Task: Executing the query "EXEC uspProgramUpdate ?" failed with the following error: "***An error occurred during processing, all transactions have been rolled back. Correct the error and restart this process.***". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
Task failed: Execute SQL - run uspProgramUpdate
The SQLStatement property of the SSIS task is:
EXEC uspCoSSleepProgramUpdate ? OUTPUT
I have the following SSIS variable:
User::EmailFailMessage (string), value = asdf
and the parameter is mapped on the SSIS SQL task in Parameter Mappings as follows:
Variable Name| Direction | Data Type | Parameter Name | Parameter Size
User::EmailFailMessage | Output | VARCHAR | #EmailFailMessage | -1
I have an email task that is being called and for that email task I have set:
MessageSource = #[User::EmailFailMessage]
When I run the SSIS package and receive the email, the message (body) of the email doesn't have the message from SQL after running the stored proc. It does have the initial value set for the User::EmailFailMessage variable and I am expecting that to change, but it isn't.
I have also tried, among other things, using 0 for the parameter name in the Parameter Mapping area of my Execute SQL Task. Using that doesn't change the result.
Personally I use the error message variable that is available in the on Error event handler called User::dataFlowExceptionMessage. That will send the exact error message sent by the failing task. That would be what bubbled up from raiserror. BUt I would suggest that you use the real error message as part of your raise error mesaage to make it easier to daignose the reason why the rollback occurred. I want to know the exact error generally.
Another thing you can do is put your error into a table variable and then insert it into an exception table with the date and the proc name after the rollback. Table variables stay in scope thorugh a rollback. Then you could look in that table to pull the message for your email task and you also have a record of just exactly what failed and when and how often which is useful for troubleshooting.
I have a SQL Server 2000 database with a stored procedure that deletes a row from a specific table, given its id. When I call the stored procedure from VB.NET, it does not delete the row, but running the same script directly on the database via SSMS, it works.
Here's my chain of events:
Start SQL Server Profiler to watch all calls to the database. I have
it setup to track when stored procedure starts, completes, and even
on SQL statements start/complete within that stored procedure.
Call stored procedure via VB.NET dll.
Stop the profiler trace to avoid excessive data to dig through.
Select from table, and see that the row still exists.
View the profiler trace, which only shows RPC:Starting, SP:Starting, RPC:Completed. No inner statements are traced, which verifies why the row wasn't deleted since the delete statement never fired.
Copy/paste the EXEC call directly from the RPC:Starting trace entry from when it was called via VB.NET, into SQL Server Management Studio query window pointed to the same database with same credentials.
Start profiler again.
Execute EXEC statement from bullet 6 in SSMS.
Stop profiler.
Select from table, and see that the row GOT DELETED like it should.
View the profiler trace, which shows SP:Starting, all statements starting/completed including the DELETE statement, and SP:Completed.
Why would running it via RPC make it not execute any of the statements in the proc, but running directly acts as it should?
EDIT: Below is my VB.NET code. This is the same code we use in over 100 other places:
Dim paramRowID As New SqlParameter("#RowID", sRowID)
Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(oConn, "spDeleteRow", paramRowID)
See SqlHelper source here.
EDIT: I hate myself right now. :) SQL threw an exception "nvarchar is incompatible with image" about another parameter that I was passing NULL to. SSMS didn't worry about the type, but VB.NET did since I didn't explicitly tell it that it was of type image. Once I defined that param, it worked. I wish profiler would have told me there was an error though.
Any help would be appreciated,
Greg
That would be because SSMS does not call an RPC but a batch. There is no way in fact to call a RPC from SSMS since you cannot declare a parameter, which is what differentiate an RPC call from a batch call in TDS:
2.2.1.3 SQL Batch To send a SQL statement or a batch of SQL statements, the SQL batch, represented by a Unicode string, is copied into the data section of a TDS packet and then sent to the database server that supports SQL. A SQL batch may span more than one TDS packet. See section 2.2.6.6 for additional detail
2.2.1.5 Remote Procedure Call To execute a remote procedure call (RPC) on the server, the client sends an RPC message data stream to the server. This is a binary stream that contains the RPC name or numeric identifier, options, and parameters. RPCs MUST be in a separate TDS message and not intermixed with SQL statements. There can be several RPCs in one message. See section 2.2.6.5 for additional details.
So monitor instead for the SQL:BatchCompleted event and you'll see your SSMS statement(s).
Does the user the application is using to connect to sql have permission to execute stored procedures? That is the first thing I would verify.
I'm running a stored procedure on server1 from my application. The stored procedure does a bunch of stuff and populate a table on server2 with the result from the procedure.
I'm using linked server to accomplish this.
When the stored procedure is done running the application continues and tries to do some manipulation of the result from the stored procedure.
My problem is that the results from the stored procedure has not been completely inserted into the tables yet, so the manipulation of the tables fails.
So my question is. Is it possible to ensure the insert into on the linked server is done synchronous? I would like to have the stored procedure not return until the tables on the linked server actually is done.
You can use an output parameter of the first procedure. When the table is create on the second server the output parameter value will be return to your application and indicates the operation is ready.
If the things are difficult then this you can try setting a different isolation level of your store procedure:
http://msdn.microsoft.com/en-us/library/ms173763.aspx
I found the reason for this strange behavior. There was a line of code in my stored procedure added during debug that did a select on a temporary mem table before the data in the same table was written to the linked server.
When the select statement was run, the control was given back to my application and at the same time the stored procedure continued running. I guess the stored procedure was running synchronously from the start.
I am using SQL Service Broker. I have a queue that another process is adding items to. I want to run a stored procedure whenever items are added to the queue. The procedure will receive the top item from the queue and use its information within the stored procedure. What is the correct syntax for doing something like this? Do I use a typical SQL Trigger or is there something special to use when working with Service Broker queues?
A triggered stored procedure can be specified as part of the queue definition.
See the documentation for CREATE QUEUE - specifically the ACTIVATION clause.
An example from the documentation:
The following example creates a queue that is available to receive
messages. The queue starts the stored procedure expense_procedure when
a message enters the queue. The stored procedure executes as the user
ExpenseUser. The queue starts a maximum of 5 instances of the stored
procedure.
CREATE QUEUE ExpenseQueue
WITH STATUS=ON,
ACTIVATION (
PROCEDURE_NAME = expense_procedure,
MAX_QUEUE_READERS = 5,
EXECUTE AS 'ExpenseUser' ) ;