You are here: Re: Inserting multiple records into two tables...with a twist « MsSQL Server « IT news, forums, messages
Re: Inserting multiple records into two tables...with a twist

Posted by --CELKO-- on 01/31/08 23:10

>> I have two tables, A and B. <<

Mind showing us their DDL?

>> I would like to insert multiple records [sic:rows are not records] into both form A [what is a form? It is not an SQL term!] and B, but a field [sic:fields are not columns] in form B is the Record ID [sic: RDBMS uses keys, not exposed physical record locators] in form A. <<

Exactly what product are you using? You are describing something that
is not SQL.

>> So, I need to insert the records into A, collect the ID and then insert into B. I have no problem doing this for individual records; I am not sure what the best way to this is for multiple records being inserted at the same time. <<

What do you mean "collect the ID"? In a relational DB, the key is a
subset of the attributes of the entity, an inherent part of it and not
something you let the hardware create when you insert a row. Next, a
table, which is nothing like a file; it is the set of one and only one
kind of entity. Thus having the same data in two tables is a
violation of basic RDBMS design -- redundancy is to be avoided via
Normal Forms and other design methods.

I would guess that you have screwed up everything because you are not
writing SQL at all. As long as you had row-at-time insertions, you
could fake a traditional file system and treat rows as if they were
records. But when you insert a set, you found out that the "set" is
the unit of work; it goes into the table all at once, in no particular
order. That is only one of many ways that rows are not records, and
tables are not files.

>> How would you accomplish this if you were me? Any help would be appreciated tremendously. <<

Learn the basics; newsgroups are places to get kludges and not an
education.

Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, data types, etc. in
your schema are. If you know how, follow ISO-11179 data element naming
conventions and formatting rules. Sample data is also a good idea,
along with clear specifications. It is very hard to debug code when
you do not let us see it.

If you want to learn how to ask a question on a Newsgroup, look at:
http://www.catb.org/~esr/faqs/smart-questions.html

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация