T-SQL & SSMS , While Loop On MS SQL Store Procedure
Create Procedure [dbo].[SP_ABC]
AS
BEGIN
DECLARE @F_DATE VARCHAR(10)
DECLARE @T_DATE VARCHAR (10)
DECLARE Hello_Cursor CURSOR FOR
SELECT A,B
FROM OPENQUERY(Oracle_SF,'Select * from ABC')
OPEN Hello_Cursor
FETCH NEXT FROM Hello_Cursor INTO
@F_Date,@T_Date
While @@Fetch_Status = 0
BEGIN
Print(@F_DATE + ' | '+ @T_DATE)
EXECUTE('Call your Procedure')
FETCH NEXT FROM Hello_Cursor INTO
@F_DATE, T_DATE
END
CLOSE Hello_Cursor
DEALLOCATE Hello_Cursor
END
留言
張貼留言