Home Forums SQL Server 2008 SQL Server Newbies How to check effect of insert statement during debugging of stored procedure RE: How to check effect of insert statement during debugging of stored procedure

  • SAMDEV (1/12/2015)


    Actually i have hard-coded value for @Rec but it gets calculated for each record being inserted from source table into destination.

    For this purpose I cannot directly insert values from source table into destination table.

    Huh? A calculation does not mean you can't do this without a cursor. Just do your calculation in a select statement.

    INSERT INTO TempAux (TempRecordID,TempFieldType,TempFieldValue,TempFieldLabel)

    SELECT SomeField * SomeOtherField + OrWhateverMakesUpYourCalculation

    , FieldType

    , ''

    , FieldLabelFROM Tab2Field

    WHERE BlockType = @BlockType

    AND FieldNumber NOT IN

    (

    Select FieldNumber

    FROM Tab2Val

    WHERE Blocktype = @BlockType

    )

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/