Is it possible to pass a variable into the select statement going to Oracle through an openquery statement?
In QueryAnalyzer, I want to:
1. read the max date in sqlserverTableA
2. delete from sqlserverTableA where date =max_date
3. select and input data from oracle_table where date>=max_date
Here is what I have so far:
DECLARE @maxdate VARCHAR(8)
begin
SET @maxdate = (select max(call_day) from TableA)
set @maxdate = @maxdate - 1
end
delete from TableA where call_day >=@maxdate
select * from openquery (connections,'select * from oracle_table
where call_day >=' + @maxdate + ')
It must be a erroneous concat issue - but I am not seeing it. The messages I get are:
Server: Msg 170, Level 15, State 1, Line 21
Line 21: Incorrect syntax near '+'.
Server: Msg 105, Level 15, State 1, Line 21
Unclosed quotation mark before the character string ' )
'.
Any ideas?
In QueryAnalyzer, I want to:
1. read the max date in sqlserverTableA
2. delete from sqlserverTableA where date =max_date
3. select and input data from oracle_table where date>=max_date
Here is what I have so far:
DECLARE @maxdate VARCHAR(8)
begin
SET @maxdate = (select max(call_day) from TableA)
set @maxdate = @maxdate - 1
end
delete from TableA where call_day >=@maxdate
select * from openquery (connections,'select * from oracle_table
where call_day >=' + @maxdate + ')
It must be a erroneous concat issue - but I am not seeing it. The messages I get are:
Server: Msg 170, Level 15, State 1, Line 21
Line 21: Incorrect syntax near '+'.
Server: Msg 105, Level 15, State 1, Line 21
Unclosed quotation mark before the character string ' )
'.
Any ideas?