For each distict company name in a table I want <BR>to get it, create and updtate a couple of records.<BR>I know FOR EACH is not correct. That the answer is probaly<BR>some form of WHILE. Im just not getting how to use it here.<BR><BR>Any Ideas?<BR>Here&#039;s my example I am trying to get working.<BR><BR><BR><BR>DECLARE @Client_Id numeric<BR>DECLARE @Company_Name varchar(100)<BR>DECLARE @Job_Count Int<BR>DECLARE @Job_Max Int<BR>DECLARE @Company_id Int<BR><BR><BR>SET @Client_Id = &#039;1157&#039;<BR><BR><BR>FOR EACH <BR><BR>SELECT company, department<BR>FROM t_job<BR>WHERE (client_id = @Client_Id)<BR>ORDER BY company<BR><BR><BR>BEGIN<BR> SET @Company_Name = (SELECT company from t_job where client_id = @Client_Id )<BR> SET @Job_Count = &#039;1&#039;<BR> SET @Job_Max = &#039;1&#039;<BR><BR> INSERT INTO t_company(company_name,Owner_id,created_by_id,job_ count,job_max)<BR> VALUES (@Company_Name,@Client_Id,&#039;894&#039;,@Job_Cou nt,@Job_Max)<BR><BR> SELECT @Company_id = @@IDENTITY<BR><BR> INSERT INTO t_user_xref(company_id,client_id)<BR> VALUES (@Company_id,@Client_Id)<BR><BR> UPDATE t_job <BR> SET<BR> company_id = @Company_id,<BR> company = @Company_Name<BR> where <BR> client_id = @Client_Id <BR>END