Suppose I have a table (all names are for illustration purposes, the original names have been withheld):
CREATE TABLE [dbo].[tblSomeName](
[ChangeDate] [DATE] NOT NULL,
[ID] [INT] NOT NULL,
[Source] [VARCHAR](100) NOT NULL DEFAULT ('Manual')
)
I would like to write a stored proc like:
CREATE PROC p_PutToTable
(
@ID [INT],
@ChangeDate [date] = NULL,
@Source [varchar] (100) = NULL
)
AS BEGIN
MERGE tblSomeName as tgt
USING (SELECT ...
If the @Source is NULL I would like to have the stored proc use the default from the table. I would like to avoid hard-coding the default specified in the table in yet another place, i.e. this stored proc. Maybe somehow query the default from the table definition? (Hoping there's a better way)