I have an OPENQUERY
statement
SELECT *
FROM OPENQUERY (NETLINE,
'SELECT * FROM XCREW.CTNAISV_HOTELCREW where RESERVATION_DATE = ''2015-05-01''')
After executing it I have error message on 2015
How to pass datetime as parameter in OPENQUERY
?
Thanks
Try this instead. Explicitly convert it to a datetime (maybe convert it to the proper datetime format you use).
SELECT *
FROM OPENQUERY (NETLINE,
'SELECT * FROM XCREW.CTNAISV_HOTELCREW where RESERVATION_DATE = CONVERT(datetime,''2015-05-01'')')
The proper format can also applied using CONVERT(datetime, N'2015-05-01', 112)
(for example).