l3nz has asked for the wisdom of the Perl Monks concerning the following question:

O wise brothers,
I have came across a couple of problems using Ado with Perl under Win32 connecting to a Ms SqlServer 7.0 database. I have no problems when executing a single Sql query but in a case I have to compute variables in the same query being sento to the database engine, like
declare @VAR int; set @VAR = (select max(id) from table); select * from table2 where id = @VAR
If I do this, the resulting recordset object shows strange behaviours, like Of course the query I'm using is by far more complex than the one I'm reporting here so replacing variables with subqueries is not a viable option.

Anybody got an idea on how to overcome this result? I cannot use DBI because it would mean a major rewrite of existing code. Thank you.