Skip to main content
added 217 characters in body
Source Link
Kevin DiTraglia
  • 26.2k
  • 20
  • 95
  • 145

Insert into xHH_QuickScan ( ScanID, EmployeeID, ProjectID, Barcode, Scandate, Scantime, ManualEntry, Category, Date1, Date2, Serial, Descrid, Date3, AssetID, Date4, AStatus, BarcodeNew, SerialNew, DescrNew ) Values ( /****** check DescID value ******/ if @AssetID = '' Begin Set @Descrid = '' End Else Begin Set @Descrid = @Descrid END End

Insert into xHH_QuickScan
(
    ScanID,
    EmployeeID,
    ProjectID,
    Barcode,
    Scandate,
    Scantime,
    ManualEntry,
    Category,
    Date1,
    Date2,
    Serial,
    Descrid,
    Date3,
    AssetID,
    Date4,
    AStatus,
    BarcodeNew,
    SerialNew,
    DescrNew
)
Values
(
/****** check DescID value ******/
if @AssetID = ''
    Begin
        Set @Descrid = ''
    End
Else
    Begin
         Set @Descrid = @Descrid
        END
End

    @ScanID,
    @EmployeeID,
    @ProjectID,
    @Barcode,
    @Scandate,
    @Scantime,
    @ManualEntry,
    @Category,
    @Date1,
    @Date2,
    @Serial,
    @Descrid,
    @Date3,
    @AssetID,
    @Date4,
    @AStatus,
    @BarcodeNew,
    @SerialNew,
    @DescrNew
)

This throws an error. I've also tried CASE, with errors. I need to test the value of @AssetID and alter the value of @Descrid accordingly

Insert into xHH_QuickScan ( ScanID, EmployeeID, ProjectID, Barcode, Scandate, Scantime, ManualEntry, Category, Date1, Date2, Serial, Descrid, Date3, AssetID, Date4, AStatus, BarcodeNew, SerialNew, DescrNew ) Values ( /****** check DescID value ******/ if @AssetID = '' Begin Set @Descrid = '' End Else Begin Set @Descrid = @Descrid END End

@ScanID,
@EmployeeID,
@ProjectID,
@Barcode,
@Scandate,
@Scantime,
@ManualEntry,
@Category,
@Date1,
@Date2,
@Serial,
@Descrid,
@Date3,
@AssetID,
@Date4,
@AStatus,
@BarcodeNew,
@SerialNew,
@DescrNew
)

This throws an error. I've also tried CASE, with errors. I need to test the value of @AssetID and alter the value of @Descrid accordingly

Insert into xHH_QuickScan
(
    ScanID,
    EmployeeID,
    ProjectID,
    Barcode,
    Scandate,
    Scantime,
    ManualEntry,
    Category,
    Date1,
    Date2,
    Serial,
    Descrid,
    Date3,
    AssetID,
    Date4,
    AStatus,
    BarcodeNew,
    SerialNew,
    DescrNew
)
Values
(
/****** check DescID value ******/
if @AssetID = ''
    Begin
        Set @Descrid = ''
    End
Else
    Begin
         Set @Descrid = @Descrid
        END
End

    @ScanID,
    @EmployeeID,
    @ProjectID,
    @Barcode,
    @Scandate,
    @Scantime,
    @ManualEntry,
    @Category,
    @Date1,
    @Date2,
    @Serial,
    @Descrid,
    @Date3,
    @AssetID,
    @Date4,
    @AStatus,
    @BarcodeNew,
    @SerialNew,
    @DescrNew
)

This throws an error. I've also tried CASE, with errors. I need to test the value of @AssetID and alter the value of @Descrid accordingly

Source Link

sql insert stored procedure with if

Insert into xHH_QuickScan ( ScanID, EmployeeID, ProjectID, Barcode, Scandate, Scantime, ManualEntry, Category, Date1, Date2, Serial, Descrid, Date3, AssetID, Date4, AStatus, BarcodeNew, SerialNew, DescrNew ) Values ( /****** check DescID value ******/ if @AssetID = '' Begin Set @Descrid = '' End Else Begin Set @Descrid = @Descrid END End

@ScanID,
@EmployeeID,
@ProjectID,
@Barcode,
@Scandate,
@Scantime,
@ManualEntry,
@Category,
@Date1,
@Date2,
@Serial,
@Descrid,
@Date3,
@AssetID,
@Date4,
@AStatus,
@BarcodeNew,
@SerialNew,
@DescrNew
)

This throws an error. I've also tried CASE, with errors. I need to test the value of @AssetID and alter the value of @Descrid accordingly