Hi, All,
When I run this stored procedures more than one times, all data are duplicated in this table? What should I do to solve this problem?
Thanks for your advance.
Jing
The following are my stored procedures:
CREATE PROCEDURE qrycount
@MC_NUM nvarchar(25),
@COMPANY_NAME nvarchar(60),
@NUM_COMPLAINTS nvarchar(20)
AS
begin
--truncate table NUM_OF_COMPLAINTS
insert into NUM_OF_COMPLAINTS
select mc_num, company_name,count(mc_num)as NUM_COMPLAINTS from complaints
where mc_num is not null group by mc_num, company_name
end
When I run this stored procedures more than one times, all data are duplicated in this table? What should I do to solve this problem?
Thanks for your advance.
Jing
The following are my stored procedures:
CREATE PROCEDURE qrycount
@MC_NUM nvarchar(25),
@COMPANY_NAME nvarchar(60),
@NUM_COMPLAINTS nvarchar(20)
AS
begin
--truncate table NUM_OF_COMPLAINTS
insert into NUM_OF_COMPLAINTS
select mc_num, company_name,count(mc_num)as NUM_COMPLAINTS from complaints
where mc_num is not null group by mc_num, company_name
end