• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to write a code for SQL Query

Hi Team

I have attached a file in which there is very large SQL Query which is used in excel as connection.
I want this query to be used in vba. but the query is so big that I am not able to collect in one variable.

So please help, how to collect this whole string in one variable to use in connection SQL via VBA.

Thanks
RatanB
 

Attachments

  • SQL Query.txt
    3.3 KB · Views: 3
Hi Ratan,

if this is static thn you can convert this querey into one line.

Hi Team

I have attached a file in which there is very large SQL Query which is used in excel as connection.
I want this query to be used in vba. but the query is so big that I am not able to collect in one variable.

So please help, how to collect this whole string in one variable to use in connection SQL via VBA.

Thanks
RatanB
 

Attachments

  • SQL Query.txt
    3.2 KB · Views: 3
Hi Ratan,

if this is static thn you can convert this querey into one line.

In query I want date to be changed accordingly whenever required. so Can it be done.... then I want this to be used in VBA Code to update the connection and table

Thanks for help
 
Suggestion from my side - it could be better if you can save your query somewhere in excel sheet with dynamic changes and then pull query in your vba code.


In query I want date to be changed accordingly whenever required. so Can it be done.... then I want this to be used in VBA Code to update the connection and table

Thanks for help
 
Because your query is too large and it may be challenging to verify or validate in VBE window.

Suggestion from my side - it could be better if you can save your query somewhere in excel sheet with dynamic changes and then pull query in your vba code.
 
Suggestion from my side - it could be better if you can save your query somewhere in excel sheet with dynamic changes and then pull query in your vba code.

I have tried this, but having concatenated the query, it is loosing all "ENTER" between new lines and keeping them without "SPACE" so unable to use tat also.
Please help in anyways if possible
 
Last but best solution, if this is regular query then you can ask your DBA team to create stored procedure or view (this is one time activity from DBA end) then you can run query on this with your condition

and if you still want to build query thru excel /vba then you have to create multiple variable or array to store this long query






I have tried this, but having concatenated the query, it is loosing all "ENTER" between new lines and keeping them without "SPACE" so unable to use tat also.
Please help in anyways if possible
 
Last edited:
Last but best solution, if this is regular query then you can ask your DBA team to create stored procedure or view (this is one time activity from DBA end) then you can run query on this with your condition

and if you still want to build query thru excel /vba then you have to create multiple variable or array to store this long query
Can you please advise how can i store this string into a varilable or in array?
 
Back
Top