I am trying to pass dates to the Sql Server Stored Procedure where i will get the dates from Oracle Database using Linked Server. This is the first time i am working on Sql Server Procedure, Could some one please help me how to get the dates from @Datesql to variables(@BeginDate, @EndDate) to further pass it to stored procedure ?
As this query results in only 1 row, Is it possible to capture the Print results in variables?
When i do Print i was getting the dates in Sql Server.
Any help would be appreciated. Thanks.
USE [dev]
GO
DECLARE @Datesql varchar(1000);
DECLARE @sysdate varchar(30) = Convert(varchar(20),GETDATE(),101);
DECLARE @BeginDate nvarchar(30);
DECLARE @EndDate nvarchar(30);
set @Datesql='SELECT TO_CHAR(A.WW_WEEK_END_DT-6,''YYYY-MM-DD''),TO_CHAR(A.WW_WEEK_END_DT,''YYYY-MM-DD'') FROM XX_PUNCH_TBL'
print @Datesql
execute(@Datesql) at orclhrdev
--SET @BeginDate='2014-12-01'
--SET @EndDate='2014-12-01'
DECLARE @return_value_Punch int
EXEC @return_value_Punch = [dbo].[XX_PUNCH] @BeginDate,@EndDate
SELECT 'Return Value' = @return_value_Punch
GO