简体   繁体   English

在 SQL 服务器中打开查询视图 Oracle 中传递日期列

[英]Pass date column in open query view Oracle in SQL Server

Can anyone please tell me if the below query is correct or Incorrect.谁能告诉我以下查询是正确还是不正确。 In this am trying to run it on SQL Server but the view is created on Oracle database.在此我尝试在 SQL 服务器上运行它,但视图是在 Oracle 数据库上创建的。 Especially date column is proper or not.特别是日期列是否正确。 as am not getting any record instead of that getting error因为我没有得到任何记录而不是得到错误

returned message "ORA-01861: literal does not match format string".返回消息“ORA-01861:文字与格式字符串不匹配”。

select *
from openquery(Oracle,'select "bs" from temp.views_employe where "Joining Date">=''2020-06-29 '' ')

I'd use the date literal syntax date '2020-06-29' so我会使用日期文字语法date '2020-06-29'所以

select * 
  from openquery(Oracle,
                 'select "bs" from temp.views_employe where "Joining Date">= date ''2020-06-29'' ')

You could also use an explicit to_date您还可以使用明确的to_date

select * 
  from openquery(Oracle,
                 'select "bs" from temp.views_employe where "Joining Date">= to_date( ''2020-06-29'', ''YYYY-MM-DD'' ) ')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM