First of all thanks for the replies mwieder :), sorry, I just want to make it work. The query works fine, until i put something like this: put "SELECT isv_laik,atv_laik, atstum ,(SELECT info FROM table_home WHERE info < atstum ) FROM reisas where gal='3' ORDER BY isv_laik" into tSQL So the question ...