locked
SQL server RRS feed

  • Question

  • Hi all,

    I am having two tables

    1st table called 'A'

    2nd table called 'B'

    Now i want to get id column from A and insert that id column into B ?

    How to make this?

    Wednesday, December 19, 2018 12:15 PM

Answers

  • you mean this?

    INSERT INTO B(idcolumn)
    SELECT idcolumn FROM A

    if IDENTITY property is set for idcolumn in B you need to first set IDENTITY_INSERT to ON

    SET IDENTITY_INSERT B ON
    GO
    
    INSERT INTO B(idcolumn)
    SELECT idcolumn FROM A
    
    SET IDENTITY_INSERT B OFF
    GO
    


    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    ----------------------------
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

    • Marked as answer by Agilvisaakan Wednesday, December 19, 2018 4:31 PM
    Wednesday, December 19, 2018 12:19 PM

All replies