Hi Freinds,
Today I had issue in applying date filter to openquery. I could not apply getdate to the coulmn as it said getdate was not allowed. When I used cast, it said column has encountered null with the below message
"An unexpected NULL value was returned for column "[MSDASQL].DateAdded" from OLE DB provider "MSDASQL" for linked server"
To overcome this error, we first declared a date parameter. We had another column which accepted the date value in some other format i,e if date was 03/03/2019 then this column would store 43495(something like this, dont remember the exact value)
i,e if it is
we then declared processing date as a paramter to accept the date value
Requirement is - Get only rows from source table in openquery where date equals todayand today minus1 or yesterday
Then we passed this date parameter in the query
'select * from openquery....where datecolumn >= ' +@ProcesingDate + '
Today I had issue in applying date filter to openquery. I could not apply getdate to the coulmn as it said getdate was not allowed. When I used cast, it said column has encountered null with the below message
"An unexpected NULL value was returned for column "[MSDASQL].DateAdded" from OLE DB provider "MSDASQL" for linked server"
To overcome this error, we first declared a date parameter. We had another column which accepted the date value in some other format i,e if date was 03/03/2019 then this column would store 43495(something like this, dont remember the exact value)
i,e if it is
we then declared processing date as a paramter to accept the date value
Requirement is - Get only rows from source table in openquery where date equals todayand today minus1 or yesterday
Then we passed this date parameter in the query
'select * from openquery....where datecolumn >= ' +@ProcesingDate + '

No comments:
Post a Comment