Re: Loop through records



On Wed, 7 May 2008 19:56:00 -0700, Michael wrote:

Hello,
i have a table that has some informatio regarding an office building in it.
It also has the building managers information in it. I want to create two
new tables. One with just the building info, and one with just the managers
info. Now, I have created the two new tables. In the building table, I have
one column that has the ManagerID. So I have written a query that imports
all the building info into the new table. Here is my question. How can I
insert (one at a time I guess) the Managers into their new table while
updating the new ManagerID into the buildings table? If i was doing this
through something like C# I would just insert one row at a time, get the new
ID, the update the second table. But I do now know how to build that type of
look in SQL. Can someone help me?

Hi Michael,

Looping through the table and processing the rows one by one would
probably be the slowest possible option. And the one that needs the most
code. Of course, if this is a one time operation, then neither of these
arguments carry much weight :)

I'd like to help you, but you didn't provide enough information. I need
the following information:

* Table structure of all tables, both input and output (posted as CREATE
TABLE statements, including all constraints, indexes and properties;
irrelevant columns may be omitted though).

* Some well-chosen rows of sample data (posted as INSERT statements)
that illustrate all regular annd exceptional cases the code should be
able to handle.

* Expected results based on the sample data (can be posted in tabular
format, but please use a fixed-width font and spaces rather than the tab
character when laying out the table). In your case, the expected results
will not be output ona screen or a report, but two sets of data for
each of the two tables.

See www.aspfaq.com/5006 for more information on how to gather and post
this additional information.

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
.



Relevant Pages

  • SendObject - attachments limit - mem issue?
    ... in a VB Module in an Access Data Project linke to SQL Server. ... There are about 120 managers in the list of managers. ...
    (microsoft.public.office.developer.outlook.forms)
  • Managing MS Project Database users
    ... their MS Project 2000 projects into a SQL Server Database. ... All users can use the DSN effectively, ... the ability to access any project. ... and wouldn't be able to access other managers' ...
    (microsoft.public.sqlserver.security)
  • Re: DBA dissappointed in sql server 2005
    ... raised your concerns directly with MS managers there. ... this would be a highly desired feature. ... > with many many databases and scores of jobs. ... > sql server from a dba point of view. ...
    (microsoft.public.sqlserver.server)
  • RE: Join on field that contains multiple items
    ... Billy Rogers ... Currently Using SQL Server 2000, ... I need to notify the Managers of the accounts. ... I want to put the returned email addresses in a table and somehow join it to ...
    (microsoft.public.access.queries)
  • Loop through records
    ... i have a table that has some informatio regarding an office building in it. ... It also has the building managers information in it. ... One with just the building info, and one with just the managers ...
    (microsoft.public.sqlserver.mseq)