I try to send a DATETIME
variable within a linked server query on a Postgres server within a SQL Server environment.
My code:
DECLARE @start_date DATETIME;
SET @start_date ='2019-02-01';
SELECT *
FROM OPENQUERY (postgresDB, 'SELECT id, action_time
FROM call_history
WHERE action_time > ''' + @start_date + ''' ')
I tried to experiment with different numbers of quotation marks around the variable, but I always get this error:
Incorrect syntax near '+'