Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.ms-sqlserver > #838
| From | Erland Sommarskog <esquel@sommarskog.se> |
|---|---|
| Newsgroups | comp.databases.ms-sqlserver |
| Subject | Re: how to insert values in two table with single query |
| Date | 2011-11-24 13:53 +0000 |
| Organization | Erland Sommarskog |
| Message-ID | <Xns9FA79778F9AC4Yazorman@127.0.0.1> (permalink) |
| References | <3dd607ca-010c-4e49-bde8-cef2d1ec603d@z22g2000prd.googlegroups.com> |
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
Back to comp.databases.ms-sqlserver | Previous | Next — Previous in thread | Next in thread | Find similar
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