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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:53:26+00:00 2026-06-05T21:53:26+00:00

I have two tables with primary foreign key relationship. The table in foreign key

  • 0

I have two tables with primary foreign key relationship.
The table in foreign key relation has some columns that can be null (not the fk column)
When I run the following sp with all the input values except the columns that can accept the null values (Path1, Path2,…Path5) the compiler throwing error that Path1, Path2…Path5 can not be null.

ALTER PROCEDURE [dbo].[Submit_Product]
    @SubjectId uniqueidentifier,
    -- ... other required parameters ...

    -- optional parameters:
    @Path1 nvarchar(75),
    @Path2 nvarchar(75),
    @Path3 nvarchar(75),
    @Path4 nvarchar(75),
    @Path5 nvarchar(75)
AS
...
  • 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-05T21:53:27+00:00Added an answer on June 5, 2026 at 9:53 pm

    I’m guessing the error is coming from your application and not from compiling the stored proc?

    In any case, you should set defaults in your stored proc like so:

    ALTER PROCEDURE [dbo].[Submit_Product]  
        (  
        @SubjectId uniqueidentifier,  
        @City nvarchar(30),  
        @Area nvarchar(20),  
        @Description nvarchar(400),  
        @ContactNo nvarchar(15),  
        @UserId int,  
        /*Fk Table*/  
        @Path1 nvarchar(75) = null,  
        @Path2 nvarchar(75) = null,  
        @Path3 nvarchar(75) = null,  
        @Path4 nvarchar(75) = null,  
        @Path5 nvarchar(75) = null 
        )  
    AS  
    

    And as a best practice, I recommend specifying column names in your insert statements to avoid future backward compatibility pitfalls…

    INSERT INTO dbo.ImagePath (Id, Path1, Path2, Path3, Path4, Path5) 
    VALUES (
      @SubjectId, 
      @Path1, 
      @Path2, 
      @Path3, 
      @Path4, 
      @Path5 
    ) 
    

    This way, you can add another column with a default value, and your existing stored procs will not be affected.

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

Sidebar

Related Questions

I have two tables, the first has a primary key that is an identity,
I have two tables that I'd like to create a foreign key for. Primary
i have two tables both are related with primary-foreign key ralation and i have
I have two SQL Server tables with Primary Keys (PK) and a Foreign Key
I have two SQL statements: CREATE TABLE legs(legid INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
I have 3 tables (Patient,Doctor,Appointments) patient has a primary key(Patient_ID)and a foreign key (Doctor_ID)
I have two database tables with the following structure: actions: action_id int(11) primary key
I have a table with two primary keys,how can i map the same in
I have a two-column primary key on a table. I have attempted to alter
i have two tables: CREATE TABLE public.auctions ( id VARCHAR(255) NOT NULL, auction_value_key VARCHAR(255)

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.