Reply to Re: help with while loops

Your name:

Reply:


Posted by David Portas on 08/23/07 22:43

<lhiregoudar@hotmail.com> wrote in message
news:1187902694.528964.278210@m37g2000prh.googlegroups.com...
> hi,
> I am trying to
> 1)get all the names of a table that match another table
> 2)while count=0, then I want to insert into another table 'group'
> after getting its key.
>
> I am totally lost, can somebody point me in the right direction.
>
> how do I get the individual name so that I can insert into the group
> table,
> I tried 'select @name=name, that gave no results'.
> Thanks
>
> while (SELECT name FROM names WHERE name in (select name from Group)
> and status = 'M' )=0
> begin
> insert into CAll(group_id,name,action) values (@key, name, 'play' )
> end
>
> how do i get the individual names to insert into another table ..
>

Why would you need a loop to do that? I don't think you will because you can
INSERT multiple rows in one statement:

INSERT INTO tbl1 (col1, col2)
SELECT col1, col2 FROM tbl2;

If you need more help, please post DDL, sample data and show your required
end result.

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--

[Back to original 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

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