sql qurery

  • hi

    Has any body got an idear why I keep getting Msg 102, Level 15, State 1, Line 1

    Incorrect syntax near 'c:'. error

    @temp_xml1 = 'INSERT INTO XMLwithOpenXML(XMLData, LoadedDateTime)SELECT CONVERT(XML, BulkColumn) AS BulkColumn, GETDATE()FROM OPENROWSET(BULK ' + 'c:\Desktop\11451.xml'+', SINGLE_BLOB) AS x'

    sorry about the spelling mistake query

  • Because you are creating dynamic sql (why in this case with a fixed name?) you need to add extra quotes to get quotes in the query, like this

    SET @temp_xml1 = 'INSERT INTO XMLwithOpenXML(XMLData, LoadedDateTime)SELECT CONVERT(XML, BulkColumn) AS BulkColumn, GETDATE() FROM OPENROWSET(BULK ''' + 'c:\Desktop\11451.xml' + ''', SINGLE_BLOB) AS x'

    Far away is close at hand in the images of elsewhere.
    Anon.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply