数据库中有两张表,A表主键为自动增长的并且是B表的外键且允许为空。现在要通过编程向B表中插入数据,可是在程序中是不允许给Int类型赋空值的如果不赋值就默认为0。为了解决这个为题最后考虑用存储过程的If Else最方便,具体的存储过程如下
存储过程中If Else的使用方法create PROCEDURE [dbo].[P_Form_Control_Info_Add]
存储过程中If Else的使用方法    
@TypeName varchar(20),
存储过程中If Else的使用方法    
@Description varchar(50),
存储过程中If Else的使用方法    
@CtlColSpan int,
存储过程中If Else的使用方法    
@Sort int,
存储过程中If Else的使用方法    
@SourceID int,
存储过程中If Else的使用方法    
@FieldID int,
存储过程中If Else的使用方法    
@TableID int
存储过程中If Else的使用方法
AS
存储过程中If Else的使用方法
if @SourceID = 0
存储过程中If Else的使用方法
begin
存储过程中If Else的使用方法
INSERT INTO T_Form_Control_Info (
存储过程中If Else的使用方法    
[TypeName],
存储过程中If Else的使用方法    
[Description],
存储过程中If Else的使用方法    
[CtlColSpan],
存储过程中If Else的使用方法    
[Sort],
存储过程中If Else的使用方法    
[FieldID],
存储过程中If Else的使用方法    
[TableID]
存储过程中If Else的使用方法
VALUES (
存储过程中If Else的使用方法    
@TypeName,
存储过程中If Else的使用方法    
@Description,
存储过程中If Else的使用方法    
@CtlColSpan,
存储过程中If Else的使用方法    
@Sort,
存储过程中If Else的使用方法    
@FieldID,
存储过程中If Else的使用方法    
@TableID
存储过程中If Else的使用方法)
存储过程中If Else的使用方法
end
存储过程中If Else的使用方法
else 
存储过程中If Else的使用方法
begin
存储过程中If Else的使用方法
INSERT INTO T_Form_Control_Info (
存储过程中If Else的使用方法    
[TypeName],
存储过程中If Else的使用方法    
[Description],
存储过程中If Else的使用方法    
[CtlColSpan],
存储过程中If Else的使用方法    
[Sort],
存储过程中If Else的使用方法    
[SourceID],
存储过程中If Else的使用方法    
[FieldID],
存储过程中If Else的使用方法    
[TableID]
存储过程中If Else的使用方法
VALUES (
存储过程中If Else的使用方法    
@TypeName,
存储过程中If Else的使用方法    
@Description,
存储过程中If Else的使用方法    
@CtlColSpan,
存储过程中If Else的使用方法    
@Sort,
存储过程中If Else的使用方法    
@SourceID,
存储过程中If Else的使用方法    
@FieldID,
存储过程中If Else的使用方法    
@TableID
存储过程中If Else的使用方法)
存储过程中If Else的使用方法
end
存储过程中If Else的使用方法
return SCOPE_IDENTITY()

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-03
  • 2022-12-23
  • 2022-12-23
  • 2021-05-22
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-12
  • 2021-12-21
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案