diff --git a/lib/arjdbc/teradata/adapter.rb b/lib/arjdbc/teradata/adapter.rb
index <HASH>..<HASH> 100644
--- a/lib/arjdbc/teradata/adapter.rb
+++ b/lib/arjdbc/teradata/adapter.rb
@@ -111,7 +111,7 @@ module ::ArJdbc
       output = nil
       pk = primary_key(table)
       if pk
-        output = execute("SELECT TOP 1 #{pk} FROM #{table} ORDER BY #{pk} DESC").first[pk]
+        output = execute("SELECT TOP 1 #{quote_column_name(pk)} FROM #{quote_table_name(table)} ORDER BY #{quote_column_name(pk)} DESC").first[pk]
       end
       output
     end
Quote table name and column name when looking for primary key