Import a large SQL query definition from a text file

  • The query definition has about 75 lines.     It is part of an Excel VBA routine in which I connect to a MS SQL database using ADO.  One reason to go with an external file is to avoid adding the line break characters such as  " & _  at the end of every line.

    I am able to retrieve my file with VBA and pass it to string variable, no problem.   When I paste it in Microsoft SQL Studio, it will trigger errors.  My query definition  becomes 4 very long lines of 2000 characters and it will truncate anywhere like a middle of a word.

    Also just a note to mention that when I retrieve the file, by code I replace a variable with an actual part number.   For example, 'SC1' can become '0270'

    Obviously I am doing it wrong.   Can somebody guide me in the right direction or offer an example.  TIA.

     

     

  • Ok, I guess that I just had to learn about stored procedures and how to start them with VBA.   Done.

  • This was removed by the editor as SPAM

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

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