SQL Server Performance

Help need for Link Server Query

Discussion in 'SQL Server 2005 General Developer Questions' started by sqlderby, Sep 18, 2010.

  1. sqlderby Member

    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...
  2. Adriaan New Member

    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.
  3. satya Moderator

Share This Page