sqlserver 存储过程中If Else的用法实例
现在要通过编程向B表中插入数据,可是在程序中是不允许给Int类型赋空值的如果不赋值就默认为0。
为了解决这个问题,用到了存储过程的If Else,下面是完整的存储过程。
代码示例:
代码如下:
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()
相关推荐
zhaojp0 2020-06-27
crowds 2020-05-06
oArvin 2020-01-03
Omega 2020-08-16
zjyzz 2020-08-16
minggehenhao 2020-07-28
zjuwangleicn 2020-06-25
wenjieyatou 2020-06-17
liaomingwu 2020-06-16
hungzz 2020-06-16
muzirigel 2020-06-14
gsmfan 2020-06-14
ncomoon 2020-06-14
xiaobaif 2020-06-13
Rain 2020-06-12
hanshangzhi 2020-06-12
talkingDB 2020-06-12
IBMRational 2020-06-09