Now you can programmatically insert data into table B, but in your program you are not allowed to assign null values to the INT type if you do not assign a value to default to 0.
To solve this problem, the if Else of the stored procedure is used, and the following is the complete stored procedure.
code example:
Copy Code code as follows:
Create PROCEDURE [dbo]. [P_form_control_info_add]
@TypeName varchar (20),
@Description varchar (50),
@CtlColSpan int,
@Sort int,
@SourceID int,
@FieldID int,
@TableID int
As
If @SourceID = 0
Begin
INSERT into T_form_control_info (
[TypeName],
[Description],
[Ctlcolspan],
[Sort],
[FieldID],
[TableID]
) VALUES (
@TypeName,
@Description,
@CtlColSpan,
@Sort,
@FieldID,
@TableID
)
End
Else
Begin
INSERT into T_form_control_info (
[TypeName],
[Description],
[Ctlcolspan],
[Sort],
[SourceID],
[FieldID],
[TableID]
) VALUES (
@TypeName,
@Description,
@CtlColSpan,
@Sort,
@SourceID,
@FieldID,
@TableID
)
End
Return scope_identity ()