getting id

Results 1 to 2 of 2

Thread: getting id

  1. #1
    Join Date
    Dec 1969

    Default getting id

    my problem is that I got 2 tables that I need to insert.until now<BR>i did it in sp like this<BR> insert into T1(a,b) values(1,1)<BR> select @id=max(id) from T1 <BR> insert into T2(c,f,T1_id) values(1,1,@id)<BR>my question is : can I get the id when I do insert ??

  2. #2
    Garth Guest

    Default RE: getting id

    Assuming SQL Server...<BR><BR>INSERT INTO T1(a,b) VALUES(1,1)<BR>SELECT @ID = @@IDENTITY<BR><BR>Garth<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts