Hi All I need help with following query as giving error "Incorrect syntax near '2010'." INSERT INTO DEL_SALE SELECT * FROM OPENQUERY(AV41,'SELECT * FROM AV.ADV_STREAM_RPT_DATA WHERE Last_Updated between '2010-08-16' AND '2010-08-18'') Thanks...
Since you're passing the query statement as a string, starting and ending with a single quote, you have to double up each and every single quote. SELECT * FROM OPENQUERY(AV41, 'SELECT * FROM AV.ADV_STREAM_RPT_DATA WHERE Last_Updated between ''2010-08-16'' AND ''2010-08-18''') Note that these are doubled single-quotes (ASCII 39) not double-quotes (ASCII 34). And yes, those are three single quotes at the end.
http://msdn.microsoft.com/en-us/library/ms188427(SQL.90).aspx FYI for more information on what Adrian referred.