You can use ISNULL
function passing in it SP's parameter as first parameter and default value in case of insert or actual column's value in case of update:
Insert into CourseDetail(CourseID, Tab1Title, Tab1Description,
Tab2Title, Tab2Description,
Tab3Title, Tab3Description, Tab4Title, Tab4Description,
Syllabus)
values (@CourseID, ISNULL(@Tab1Title, 'default value'), ISNULL(@Tab1Description,'default value'), ...
Update CourseDetail
SET
Tab1Title = ISNULL(@Tab1Title, Tab1Title),
Tab1Description = ISNULL(@Tab1Description, Tab1Description),
....
Where
CourseID = @CourseID
But in this case you won't can to set NULL value explicitely even if you'll need
manpreet
Best Answer
2 years ago
I want to create an insert stored procedure with null parameters, if pass the value for that parameter then it has to insert or update in database
My stored procedure is: