ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   problem (https://www.excelbanter.com/excel-programming/368132-problem.html)

[email protected]

problem
 
Hi

I have a problem in excel when i try to import data from MSSql with
Import
external data: I must use the same condition in two places in the same
query..something like that:

select col2 from d where col1=? union select col3 from d where id not
in
(select col2 from d where col1=?)

this query works perfectly in MSSql, but when I try to do this in my
".dqy"
file the excel tell me I have an error in my sql...

pls help me


NickHK

problem
 
MSQuery seems to expect a separate input for each parameter; it cannot tell
that "col1" is repeated and the repeat seems to cause a problem.
If you call the second instance something else, does it work ?
Also, how are you filling the parameters ?

NickHK

wrote in message
oups.com...
Hi

I have a problem in excel when i try to import data from MSSql with
Import
external data: I must use the same condition in two places in the same
query..something like that:

select col2 from d where col1=? union select col3 from d where id not
in
(select col2 from d where col1=?)

this query works perfectly in MSSql, but when I try to do this in my
".dqy"
file the excel tell me I have an error in my sql...

pls help me




[email protected]

problem
 

NickHK wrote:
MSQuery seems to expect a separate input for each parameter; it cannot tell
that "col1" is repeated and the repeat seems to cause a problem.
If you call the second instance something else, does it work ?
Also, how are you filling the parameters ?

NickHK

wrote in message
oups.com...
Hi

I have a problem in excel when i try to import data from MSSql with
Import
external data: I must use the same condition in two places in the same
query..something like that:

select col2 from d where col1=? union select col3 from d where id not
in
(select col2 from d where col1=?)

this query works perfectly in MSSql, but when I try to do this in my
".dqy"
file the excel tell me I have an error in my sql...

pls help me


yes...if I put, for example, a static value:
select col2 from d where col1=? union select col3 from d where id not
in
(select col2 from d where col1='X')
is working


NickHK

problem
 
Can't you set the parameter values to cell values ?
So both "col1" value point to the same cell.

NickHK

wrote in message
oups.com...

NickHK wrote:
MSQuery seems to expect a separate input for each parameter; it cannot

tell
that "col1" is repeated and the repeat seems to cause a problem.
If you call the second instance something else, does it work ?
Also, how are you filling the parameters ?

NickHK

wrote in message
oups.com...
Hi

I have a problem in excel when i try to import data from MSSql with
Import
external data: I must use the same condition in two places in the same
query..something like that:

select col2 from d where col1=? union select col3 from d where id not
in
(select col2 from d where col1=?)

this query works perfectly in MSSql, but when I try to do this in my
".dqy"
file the excel tell me I have an error in my sql...

pls help me


yes...if I put, for example, a static value:
select col2 from d where col1=? union select col3 from d where id not
in
(select col2 from d where col1='X')
is working





All times are GMT +1. The time now is 11:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com