On Wednesday, July 8, 2020 at 3:38:00 PM UTC-7, KING SABRI wrote: > > Hi all > > I'm trying to use OPENQUERY using sequel and I'm always getting syntax > error > > >> @db["SELECT * FROM OPENQUERY(\"SQL02.DEV\" , 'SELECT @@version')"].all > > > *The error is * > > Sequel::DatabaseError: TinyTds::Error: Incorrect syntax near 'SQL02.DEV'. > from > /var/lib/gems/2.7.0/gems/sequel-5.34.0/lib/sequel/adapters/tinytds.rb:217:in > `fields' > Caused by TinyTds::Error: Incorrect syntax near 'SQL02.DEV'. > from > /var/lib/gems/2.7.0/gems/sequel-5.34.0/lib/sequel/adapters/tinytds.rb:217:in > `fields' > Caused by Sequel::DatabaseError: TinyTds::Error: Unclosed quotation mark > after the character string '''. > from > /var/lib/gems/2.7.0/gems/sequel-5.34.0/lib/sequel/adapters/tinytds.rb:217:in > `fields' > Caused by TinyTds::Error: Unclosed quotation mark after the character > string '''. > from > /var/lib/gems/2.7.0/gems/sequel-5.34.0/lib/sequel/adapters/tinytds.rb:217:in > `fields' > > I've tried various ways to by changing double-quotes to single-quotes, > quotes escaping but no luck. > > PS: Queries such as SELECT @@version work well. The issue I'm facing is > only with OPENQUERY. > > -> Sequel::VERSION > => 5.34.0 >
>From looking at the OPENQUERY documentation, the first argument does not appear to need quoting: https://docs.microsoft.com/en-us/sql/t-sql/functions/openquery-transact-sql?view=sql-server-ver15 In any case, this doesn't appear to be a problem with Sequel, as Sequel is raising an error because your SQL is invalid. If you continue to need help on producing valid SQL for OPENQUERY, you should probably ask on an MSSQL-specific forum. Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sequel-talk/6dc735a9-5f01-4ffc-a366-f9005698708fo%40googlegroups.com.
