Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8143461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:07:46+00:00 2026-06-06T13:07:46+00:00

On our SQL Server (Version 10.0.1600), I have a stored procedure that I wrote.

  • 0

On our SQL Server (Version 10.0.1600), I have a stored procedure that I wrote.

It is not throwing any errors, and it is returning the correct values after making the insert in the database.

However, the last command spSendEventNotificationEmail (which sends out email notifications) is not being run.

I can run the spSendEventNotificationEmail script manually using the same data, and the notifications show up, so I know it works.

Is there something wrong with how I call it in my stored procedure?

[dbo].[spUpdateRequest](@packetID int, @statusID int output, @empID int, @mtf nVarChar(50)) AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    DECLARE @id int
    SET @id=-1
    -- Insert statements for procedure here
    SELECT A.ID, PacketID, StatusID
    INTO #act FROM Action A JOIN Request R ON (R.ID=A.RequestID)
    WHERE (PacketID=@packetID) AND (StatusID=@statusID)

    IF ((SELECT COUNT(ID) FROM #act)=0) BEGIN -- this statusID has not been entered. Continue

        SELECT ID, MTF
        INTO #req FROM Request
        WHERE PacketID=@packetID

        WHILE (0 < (SELECT COUNT(ID) FROM #req)) BEGIN
            SELECT TOP 1 @id=ID FROM #req
            INSERT INTO Action (RequestID, StatusID, EmpID, DateStamp)
            VALUES (@id, @statusID, @empID, GETDATE())
            IF ((@mtf IS NOT NULL) AND (0 < LEN(RTRIM(@mtf)))) BEGIN
                UPDATE Request SET MTF=@mtf WHERE ID=@id
            END
            DELETE #req WHERE ID=@id
        END
        DROP TABLE #req

        SELECT @id=@@IDENTITY, @statusID=StatusID FROM Action

        SELECT TOP 1 @statusID=ID FROM Status
        WHERE (@statusID<ID) AND (-1 < Sequence)

        EXEC spSendEventNotificationEmail @packetID, @statusID, 'http:\\cpweb:8100\NextStep.aspx'

    END ELSE BEGIN

        SET @statusID = -1

    END

    DROP TABLE #act

END

Idea of how the data tables are connected:

my database

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T13:07:47+00:00Added an answer on June 6, 2026 at 1:07 pm

    From your comments I get you do mainly C# development. A basic test is to make sure the sproc is called with the exact same arguments you expect

    PRINT '@packetID: ' + @packetID
    PRINT '@statusID: ' + @statusID
    EXEC spSendEventNotificationEmail @packetID, @statusID, 'http:\\cpweb:8100\NextStep.aspx'
    

    This way you 1. know that the exec statement is reached 2. the exact values

    If this all works than I very good candidate is that you have permission to run the sproc and your (C#?) code that calls it doesn’t. I would expect that an error is thrown tough.

    A quick test to see if the EXEC is executed fine is to do an insert in a dummy table after it.

    Update 1

    I suggested to add PRINT statements but indeed as you say you cannot (easily) catch them from C#. What you could do is insert the 2 variables in a log table that you newly create. This way you know the exact values that flow from the C# execution.

    As to the why it now works if you add permissions I can’t give you a ready answer. SQL security is not transparent to me either. But its good to research yourself a but further. Do you have to add both guest and public?
    It would also help to see what’s going inside spSendEventNotificationEmail. Chances are good that sproc is using a resource where it didn’t have permission before. This could be an object like a table or maybe another sproc. Security is heavily dependent on context/settings and not an easy problem to tackle with a Q/A site like SO.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

TL;DR version: Please confirm (or if not, provide assistance) that I'm getting SQL Server
GUID is not an official data type in database. In our existing SQL Server
Our application uses Hibernate with Sql Server 2005. Being a DBA, I am not
Our application uses a SQL Server back-end with many stored procedures. Recently, while trying
The past two times we have rebooted our sql server, our website has gone
Our SQL 2005 server has a Maintenance Plan that cannot be deleted. When I
We are converting our application from using Sql Server Express (let's call this version
We have a production SQL Server 2005 database server with the production version of
I need to add a new stored procedure on our company's MySQL server. Since
For our SQL Server database, we're using a versioning scheme to track schema updates.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.