Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.databases.ms-sqlserver    |    Notorious Rube Goldberg contraption    |    19,505 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 18,524 of 19,505    |
|    Erland Sommarskog to Pab    |
|    Re: how to insert values in two table wi    |
|    24 Nov 11 13:53:25    |
   
   9bbce472   
   From: esquel@sommarskog.se   
      
   Pab (prabu.net88@gmail.com) writes:   
   > i am trying to insert data two table with single query with   
   > foreign key reference but its not working   
   > my query is   
   > BEGIN TRANSACTION   
   > DECLARE @salid int   
   > Insert into sal_products (upc,shelf_number,aisle_no) values   
   > ('123asd','N/A','N/A','N/A','N/A',100)   
   > select @salid = scope_identity()   
   > insert into sal_product_locations (sal_product_id,side,position)   
   > values (@salid,'N/A','N/A')   
   > commit   
   > could any one provide me solution for this   
      
   What does "not working" mean? Do you get unexpected results? Do you get an   
   error message? In such case, please share it. Something else?   
      
   A quick look indicates that in the first INSERT statement you list three   
   columns and five values. That is not going to work out.   
      
      
   --   
   Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se   
      
   Books Online for SQL Server 2005 at   
   http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx   
   Books Online for SQL Server 2000 at   
   http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca