I am trying to migrate a system across and need some help tidying data and merging info.
Firstly if I have some companies with the suffix 'Limited' and some with 'Ltd' ie BBC Ltd and BBC Limited. How do I change all these to read the company name and then Ltd??
Secondly I am pulling info from a table which has company name duplicates into a table that also may have company details relating to that company name. I wish to add the details if the company name doesn't exist in the table and also only input the once from the source table. I am using cursors for this. My scripts see below is adding every record. Any ideas why??
Thanks for any suggestions


CREATE PROCEDURE check_company2
AS
declare
@id varchar(50),
@company_name varchar(50),
@business_type varchar(50),
@hardware varchar(50),
@operating_system varchar(50),
@networks varchar(50),
@pcs varchar(50),
@terminals varchar(50),
@test_companies_id varchar(50)
begin
declare s_completelist_cur cursor for select [company name],[business type],[hardware],[operating system],[networks],
[pcs],[terminals] from s_completelist
open s_completelist_cur

fetch next from s_completelist_cur into @company_name, @business_type, @hardware, @operating_system, @networks,@pcs, @terminals
while (@@fetch_status=0)

begin
print @company_name
select @test_companies_id from companydetails c where c.company_name = @company_name
if @test_companies_id is not null

begin
print 'match found'
end
else
begin
insert into companydetails ( company_name, business_type,hardware, op_system, network, pcs, terminals)
values (@company_name, @business_type,@hardware, @operating_system, @networks, @pcs, @terminals)
end

fetch next from s_completelist_cur into @company_name, @business_type, @hardware, @operating_system, @networks,@pcs, @terminals
end
close s_completelist_cur
deallocate s_completelist_cur
end