On Fri, May 17, 2019 at 9:43 AM Massi <[email protected]> wrote:
>
> Hi,
>
> I'm trying to issue a query in SQL Server via select(cols, cond, ...) and I 
> would like to add collation at query execution time for executing the query 
> in a case sensitive mode.
> I tried this:
>
> cond = and_(tab.c.col3=="mystring1", tab.c.col2=="mystring2")
> cond = cond.collate("SQL_Latin1_General_CP1_CS_AS")
> q = select([tab.c.col3, tab.c.col4], cond, ...)
> ...
>
> But that is raising a syntax error.
>
> (SQLExecDirectW); [42000] [Microsoft][ODBC SQL Server Driver][SQL 
> Server]Incorrect syntax near 'COLLATE'. (102); [42000] [SQL: u'SELECT 
> tab.col3, tab.col4 \nFROM tab \nWHERE (tab.col1 = ? AND tab.col2 = ?) COLLATE 
> SQL_Latin1_General_CP1_CS_AS'] [parameters: (u'mystring1', u'mystring2')] 
> (Background on this error at: http://sqlalche.me/e/f405)

I believe the COLLATE needs to be for each WHERE criteria
individually?   very hard to find examples on the web but I found
https://www.red-gate.com/simple-talk/sql/sql-development/questions-sql-server-collations-shy-ask/


so


select().where(and_((tab.c.col3 == 'ms').collate(...), (tab.c.col2 ==
'm2').collate()))



>
>
>  Can anyone help me on how to achieve this?
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and 
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> description.
> ---
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sqlalchemy.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/5db87be0-bb3e-400b-b1c6-6a49bdf20c7c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/CA%2BRjkXHsU3hP4zV7Tn%2Bf5QGaQKH2Jp%3D1jHMtRWT3h14m9%3DsswA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to