SQLContainer to SQLServer 2008

Hi, I am trying to use a TableQuery to a table on a SQLServer DB. I get the following error
‘Primary key constraints have not been defined for the table’ when I try to connect. There is a primary key contraint created so I am somewhat bemused by the error.

any help would be appreciated. I am sure it has something to do with SQLServer, I havnt had an issue like it on MySQL.


ON further investigation, it looks like the issue is that the table is part of a specific schema. If I create the same table against the standard dbo schema it works perfectly… soon as I move it to its own schema it seems to cause a problem… I tried to reference the table using the full schema reference when creating the tablequery but it doent like that, it says the table doesnt exist.

anybody know how to specify a schema against a table query?


Typically the schema is associated with the user used to log in to the database. Log in to the database using a user whose default schema is the one you want.

Thanks, while that did work it seems that perhaps TableQuery has compatibility issues with SQLServer. It seems to by trying to use the ‘limit’ keyword in the
generated SQL which is not supported by SQLServer.

it looks like I should stop being lazy and just use FreeFormQuery instead.

thanks for your help.

Are you using MSSQLGenerator for the TableQuery (constructor parameter to TableQuery)? Oracle and Microsoft databases require their own query generators that take care of some differences in SQL syntax.

:*) thats a bit embarressing!.. pays to actually read the javadoc doesnt it!

thanks very much, that simplifies things nicely.