Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to get data from a remote SQL 2000 server and store it in a new MySQL server. I am using the FreeTSD module for php 5.3 to connect to the SQL 2000 server. I can connect without problems.

Here's my issue; one particular table isn't yielding any result to this query:


But this query is successful when I test it SQL Query Analyzer.

I do get results (also remote) when I change it to:


The Item table holds over 500K records and I'm thinking that that might have something to do with it. Could that be the issue and how can I work around that. I have tried this without result:


This is the php code to connect:

try {
    $db = new PDO('odbc:Driver=FreeTDS;; Port=1433; Database=xxxxx; UID=xxxxx; PWD=xxxxxx;');
} catch(PDOException $exception) {
    die("Unable to open database.<br>Error message:<br><br>$exception.");

And this is the select code:

$query = "SELECT * FROM Item";
$statement = $db->prepare($query);
$data = $statement->fetchAll(PDO::FETCH_ASSOC);

echo '<pre>';
echo '</pre>';

Which returns an empty array.

share|improve this question
What does "isn't yielding any result" mean? It returns immediately with 0 row(s), it returns an error, it runs forever, ...? Are there permissions differences between the two tables? What does your PHP code look like? – Aaron Bertrand Jun 6 '13 at 15:09
It means that it returns immediately with 0 rows without any error message. There aren't any permission differences between the two tables. I've added the php code to the original post. – Abel Jun 6 '13 at 18:27
So did you try SELECT c = COUNT(*) FROM Item? How about just a single column instead of all? – Aaron Bertrand Jun 6 '13 at 18:39
Yes, this is the result: array(1) { [0]=> array(1) { ["c"]=> string(6) "180783" } } – Abel Jun 6 '13 at 18:59
Try specifying a table schema. "SELECT * FROM dbo.Item", not "SELECT * FROM Item". Many devs get into trouble when they accidentally create, then query, tables in different schema without realizing that they actually have two copies of the table: one empty and one with data. – darin strait Jun 6 '13 at 19:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.