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
...
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:
And as a best practice, I recommend specifying column names in your insert statements to avoid future backward compatibility pitfalls…
This way, you can add another column with a default value, and your existing stored procs will not be affected.