I am trying to add the COLLATE function to a .net SqlCommand. But I am not getting any results. I have tested the logic in Mgmt Studio, where it works, there should be data returned with this SELECT stmt. The query works with the exception of Collation filter.

        Dim sql1 As String = "SELECT lang_String FROM " & tableName & " WHERE short_Text COLLATE Latin1_General_CS_AS = @englishText "

The query worked prior to adding the following syntax...

COLLATE Latin1_General_CS_AS

The database is set to Case Insensitive and needs to stay that way. I just want to be able to apply COLLATION during certain queries. As can be done within MgmtStudio.

Any ideas on how to get the .net operation to properly execute?

Thanks,

有帮助吗?

解决方案 2

I had to stuff it all into a STORED PROCEDURE. Works fine now, I still think this is a bug for MS to look into though.

其他提示

You might be getting a collation error. Try putting the COLLATE on both sides:

    Dim sql1 As String = "SELECT lang_String FROM " & tableName & " WHERE short_Text COLLATE Latin1_General_CS_AS = @englishText COLLATE Latin1_General_CS_AS" 

Otherwise the syntax looks ok.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top