Solved

SQL Query Syntax Error

Posted on 2009-07-07
2
265 Views
Last Modified: 2013-11-16
Hello.

I need to make a dynamic query to RSMain based on the RSIndex id_indexador. But its not working this way...

Please help!

Thanks in advance!

comando = "SELECT * FROM tbl_Indexador" 
call abrers(comando, "listar", RSIndex)
 
DO WHILE NOT RSIndex.EOF 
comando = "SELECT * FROM tbl_Cotacao where dt_cotacao = '"&dt&"' and id_indexador = "& RSIndex("id_indexador")
call abrers(comando, "listar", RSMain&RSIndex("id_indexador"))
RSIndex.MoveNext
loop

Open in new window

0
Comment
Question by:drix76
  • 2
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 24793335
what about combining this into 1 query:
comando = "SELECT * FROM tbl_Cotacao where dt_cotacao = '"&dt&"' and id_indexador IN ( select id_indexador FROM tbl_Indexador ) "
call abrers(comando, "listar", RSIndex)

Open in new window

0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24793340
apart from that: what error do you get, on which line, etc ..?
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Server Count where two id types exist in column 8 27
SQL Server 2012 r2 - Sum totals 2 25
Sql server function help 15 31
awk and Pythagoras? 5 7
This article describes some very basic things about SQL Server filegroups.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question