SP Not Inserting A New Row

I create this SP and I am expecting it to insert a new row but that is not happening.  What's the best way to handle this?

 (@BatchID         9cfb9462-6b85-495c-9b66-db2e8d41329a)


======================================================================

ALTER PROCEDURE [dbo].[PushNotificationBatchWrite]
      (
      @BatchID                          uniqueidentifier,
      @SentYN                        char(1) = null,
      @SentTimestamp            datetime = null,
      @MFUpdatedYN                    char(1) = null,
      @MFUpdatedTimestamp      datetime = null
      )
AS

IF (@SentYN = NULL) AND (@MFUpdatedYN = NULL)
      --insert the new batch ID row
      BEGIN
            SET NOCOUNT ON;

            INSERT INTO [dbo].[PushNotificationBatch] (BatchID) VALUES (@BatchID);

            SET NOCOUNT OFF;
      END
ELSE
      BEGIN
            IF @MFUpdatedYN IS NOT NULL
                  BEGIN
                        --set the batch ID as updated on the mainframe

                        UPDATE [dbo].[PushNotificationBatch]
                           SET [MFUpdatedYN] = @MFUpdatedYN
                                ,[MFUpdatedTimestamp] = @MFUpdatedTimestamp
                         WHERE BatchID = @BatchID
                        
                   END

            IF @SentYN IS NOT NULL
                  BEGIN
                        --set the batch ID as sent to the vendor
                        UPDATE [dbo].[PushNotificationBatch]
                           SET [SentYN] = @SentYN
                                ,[SentTimestamp] = @SentTimestamp
                         WHERE BatchID = @BatchID
                        
                   END
      END
faith victoryAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vaibhav GoelMSBI , SQL ConsultantCommented:
HELLO faith Victory

Please make an attempt to use changed code provided->

======================================================================

ALTER PROCEDURE [dbo].[PushNotificationBatchWrite]
      (
      @BatchID                          uniqueidentifier,
      @SentYN                        char(1) = null,
      @SentTimestamp            datetime = null,
      @MFUpdatedYN                    char(1) = null,
      @MFUpdatedTimestamp      datetime = null
      )
AS

IF (@SentYN IS NULL) AND (@MFUpdatedYN IS NULL)
     
      BEGIN
            SET NOCOUNT ON;

                        INSERT INTO [dbo].[PushNotificationBatch] (BatchID) VALUES (@BatchID);

            SET NOCOUNT OFF;
      END
ELSE
      BEGIN
            IF @MFUpdatedYN IS NOT NULL
                  BEGIN
                        --set the batch ID as updated on the mainframe

                        UPDATE [dbo].[PushNotificationBatch]
                           SET [MFUpdatedYN] = @MFUpdatedYN
                                ,[MFUpdatedTimestamp] = @MFUpdatedTimestamp
                         WHERE BatchID = @BatchID
                       
                   END

            IF @SentYN IS NOT NULL
                  BEGIN
                        --set the batch ID as sent to the vendor
                        UPDATE [dbo].[PushNotificationBatch]
                           SET [SentYN] = @SentYN
                                ,[SentTimestamp] = @SentTimestamp
                         WHERE BatchID = @BatchID
                       
                   END
      END


Vaibhav
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Nakul VachhrajaniTechnical Architect, Capgemini IndiaCommented:
How do you call the stored procedure? What parameters are you passing from your calling code? It looks like @SentYN and @MFUpdatedTimestamp are not being passed as NULL.
0
Brian CroweDatabase AdministratorCommented:
No value ever equals NULL including NULL itself.  To check for NULL use the "IS" operator.

IF (@SentYN IS NULL) AND (@MFUpdatedYN IS NULL)
0
faith victoryAuthor Commented:
Best solution!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.