Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #837

how to insert values in two table with single query

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!news-out.readnews.com!news-xxxfer.readnews.com!postnews.google.com!z22g2000prd.googlegroups.com!not-for-mail
From Pab <prabu.net88@gmail.com>
Newsgroups comp.databases.ms-sqlserver
Subject how to insert values in two table with single query
Date Thu, 24 Nov 2011 05:27:11 -0800 (PST)
Organization http://groups.google.com
Lines 15
Message-ID <3dd607ca-010c-4e49-bde8-cef2d1ec603d@z22g2000prd.googlegroups.com> (permalink)
NNTP-Posting-Host 122.183.186.5
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
X-Trace posting.google.com 1322141231 15672 127.0.0.1 (24 Nov 2011 13:27:11 GMT)
X-Complaints-To groups-abuse@google.com
NNTP-Posting-Date Thu, 24 Nov 2011 13:27:11 +0000 (UTC)
Complaints-To groups-abuse@google.com
Injection-Info z22g2000prd.googlegroups.com; posting-host=122.183.186.5; posting-account=uS-mcwoAAAD29CtafUF8QC_5Mg8ZDyvG
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-Header-Order HRUAELSCNK
X-HTTP-UserAgent Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Ubuntu/10.04 Chromium/12.0.742.112 Chrome/12.0.742.112 Safari/534.30,gzip(gfe)
Xref x330-a1.tempe.blueboxinc.net comp.databases.ms-sqlserver:837

Show key headers only | View raw


Hi,
     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
thanks,
-pab

Back to comp.databases.ms-sqlserver | Previous | NextNext in thread | Find similar


Thread

how to insert values in two table with single query Pab <prabu.net88@gmail.com> - 2011-11-24 05:27 -0800
  Re: how to insert values in two table with single query Erland Sommarskog <esquel@sommarskog.se> - 2011-11-24 13:53 +0000
    Re: how to insert values in two table with single query Pab <prabu.net88@gmail.com> - 2011-11-24 06:13 -0800
      Re: how to insert values in two table with single query "Bob Barrows" <reb01501@NOSPAMyahoo.com> - 2011-11-24 10:37 -0500
      Re: how to insert values in two table with single query Erland Sommarskog <esquel@sommarskog.se> - 2011-11-24 23:35 +0100
  Re: how to insert values in two table with single query --CELKO-- <jcelko212@earthlink.net> - 2011-11-25 08:22 -0800

csiph-web