SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Store Procedure Name]
AS
BEGIN
DECLARE @tmp TABLE
(
Fieldname varchar(500),
Fieldname varchar(500)
)
Declare @temp_Fieldname varchar(500)
declare @temp_Fieldname varchar(500)
declare @count int
DECLARE PROCEDURE_CURSOR CURSOR FOR
select Fieldname,Fieldname from Table where DATEDIFF (dd,importdt,GETDATE()) = 0
OPEN PROCEDURE_CURSOR
FETCH NEXT FROM PROCEDURE_CURSOR INTO @temp_Fieldname,@temp_Fieldname
WHILE @@FETCH_STATUS = 0
BEGIN
select @count = count(Fieldname) from @tmp where Fieldname = @temp_Fieldname
if (@count = 0)
begin
insert into @tmp values(@temp_Fieldname,@temp_Fieldname)
end
else
begin
insert into @tmp (Fieldname) values(@temp_Fieldname)
end
FETCH NEXT FROM PROCEDURE_CURSOR INTO @temp_Fieldname,@temp_Fieldname
END
CLOSE PROCEDURE_CURSOR
DEALLOCATE PROCEDURE_CURSOR
Select * from @tmp
END
No comments:
Post a Comment