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 8743293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:39:00+00:00 2026-06-13T11:39:00+00:00

I have a (legacy) VB6 program that needs some work. I have a stored

  • 0

I have a (legacy) VB6 program that needs some work. I have a stored procedure that updates a table of vendors. In this particular form, I don’t need to update the entire row, just 10 or so columns out of the 20ish.

Here is some pseudo code that works fine if I want to update the entire row:

CREATE PROCEDURE [dbo].[spUpdateVendor](
    @pID INT,
    @pVendorID varchar(254), 
    @pVendorName varchar(255),
    @pContact varchar(255),
    @pEmail varchar(255),
    ...)
AS
BEGIN
SET NOCOUNT ON;
SET XACT_ABORT ON

DECLARE @ErrorMessage nvarchar(4000);

BEGIN TRY
-- Start the transaction
    BEGIN TRANSACTION
        UPDATE tblVendor
            SET
                [Vendor ID] = @pVendorID,
                [Vendor Name] = @pVendorName,
                [Contact] = @pContact,
                [email] = @pEmail
                ...
            WHERE
                [ID] = @pID
    COMMIT TRANSACTION;
END TRY

If I want to only update some of the columns with data here is the (pseudo) code I have been trying (attempt at using optional parameters):

CREATE PROCEDURE [dbo].[spUpdateVendor2](
    @pID INT,
    @pVendorID varchar(254) = NULL, 
    @pVendorName varchar(255) = NULL,
    @pContact varchar(255) = NULL,
    @pEmail varchar(255) = NULL,
    ...)
AS
BEGIN
SET NOCOUNT ON;
SET XACT_ABORT ON

DECLARE @ErrorMessage nvarchar(4000);

BEGIN TRY
-- Start the transaction
    BEGIN TRANSACTION
        UPDATE tblVendor
            SET
                [Vendor ID] = ISNULL(@pVendorID,[Vendor ID]),
                [Vendor Name] = ISNULL(@pVendorName,[Vendor Name]),
                [Contact] = ISNULL(@pContact,[Contact]),
                [Email] = ISNULL(@pEmail,[email]),
                ...
            WHERE
                [ID] = @pID 
    COMMIT TRANSACTION;
END TRY

and it all runs w/o errors but it will update the wrong column if I update one optional column, skip a few, then update another optional column.

Example of update using normal parameters:

tblVendor
ID: 2924
Vendor ID: Company1
Vendor Name: Company Name
Contact: Bob
email: bob@company.com

Example of updating via the optional parameters when I don’t supply ‘contact’:

tblVendor
ID: 2924
Vendor ID: Company1
Vendor Name: Company Name
Contact: bob@company.com
email: bob@company.com

SO it updates the row, but it updates the wrong column. What am I doing incorrectly?

  • 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-13T11:39:00+00:00Added an answer on June 13, 2026 at 11:39 am

    You have to explicitly specify parameter names when executing stored procedure and pass in null for those you want to leave out. Example

    exec spUpdateVendor2 @pID=102, @pVendorID = 1, @pVendorName = NULL, @pContact = 'Contact',
    @pEmail = NULL ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a legacy stored procedure that I'm trying to modify. This is a
We have a legacy VB6 application that updates itself on startup by pulling down
I have a legacy vb6 application that needs to run on a server 2008
We have a legacy VB6 application that is very procedural. This thing is gigantic!
I have to work on several VB6 legacy projects and despite some good VB6
We have a legacy VB6 application that uses Crystal Reports XI to generate printed
We have a legacy VB6 component that was com+/MTS and is used by asp
I have a legacy VB6 app that I still need to support. I also
I have inherited some legacy vb6 code. It's a tool which generates a local
We have a legacy component that has been converted from VB6 to VB.Net. The

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.