hi !

Ive been googling for a while and I havnt found a solution to convert MySQL queries to MSSQL queries

The main problem, I think , resides on the LIMITs and such

Before I start reinventing the wheel I wanted to ask the experts if anyone knew or had a class to convert MySQL querys to MSSQL querys

Thanks in advance

    I don't know of a class to convert them, but then again I tend to write SQL '99 standard code which works on all SQL servers. I'm thinking you might have to just manually go through and fix them yourself.

      But i'd love to keep working on my system for mysql, and in case someone wants to use it on MSSQL he could without having to arrage again manually all the querys =(

      Ive been thinking, I could analyze the query and break it into its main parts so I could rearrange em to do whatever i need.

      I think the only uncompatible thing in my querys are the LIMITs

        There are alternative ways to limit results. You could use php to do just that. The LIMIT clause is a MySQL extension of the SQL language, so that would have to be dropped. But you could fix this in php using:

        $result = mysql_query($query);
        
        $num = mysql_num_rows($result);
        
        $start = 10;
        $limit = 15;
        
        $i=1;
        while($row = mysql_fetch_assoc($result))
        {
            if($i>=$start && $i< ($start+$limit))
                $results[] = $row;
        
        $i++;
        }

        Then your requested rows are in the $results array.

          indeed, however imagine using this on a table with 600,000 rows I'd had the database transferme the 600,000 rows just to cut the first 10 ?

          besides, limits boost the query speed :/

            indeed, however imagine using this on a table with 600,000 rows I'd had the database transferme the 600,000 rows just to cut the first 10 ?

            It probably depends on the implementation, but the database does not have to transfer the data from all 600K rows, only those that have been accessed via the result set cursor.

              Write a Reply...