Skip to content
Loading
  • Nitin Sontakke
    0
    All you have to do is make it a part of the transaction and roll it back in case of the error. Please be aware that the identity values once incremented cannot be rolled back.
     
    I will be surprised if it can be done in a single query.
    0
  • 0
    yes sir .i dont think i can achieve it with single query .but one of my friend achieved it.so i m trying it for past 2 hours .at last i m here
    there is no concern about errors and all.he said while inserting 2 tables first table ID which incremented is captured and insert that one in to second table .in a single button click .
    0
  • 0
    Here we go...................
     
    Try below code 
     
    create table employee
    (empid int,empname varchar(100),empcity varchar(100))
    create table employee_details
    (empid int,emp_depart varchar(100),emp_city varchar(100))
    insert into employee (empid,empname,empcity) OUTPUT inserted.empid,inserted.empcity into employee_details (empid,emp_city)
    values (1,'Manish','Delhi')
    select * from employee
    select * from employee_details
    0
  • Bikesh Srivastava
    0
    Yes 100%
    just you need to create relational database with foreign key between two table.
    it will insert in both table an can be get eaisly . 
    0