Take the 2-minute tour ×
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. It's 100% free, no registration required.

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:

SELECT * FROM Item

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

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

SELECT * FROM Brands

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:

SELECT TOP 10 * FROM Item

This is the php code to connect:

try {
    $db = new PDO('odbc:Driver=FreeTDS; Server=xxx.xxx.xxx.xxx; 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);
$statement->execute();
$data = $statement->fetchAll(PDO::FETCH_ASSOC);

echo '<pre>';
var_dump($data);
echo '</pre>';

Which returns an empty array.

share|improve this question
4  
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

 
discard

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

Browse other questions tagged or ask your own question.