How to do a case sensitive GROUP BY?

You need to cast the text as binary (or use a case-sensitive collation). With temp as ( select ‘Test’ as name UNION ALL select ‘TEST’ UNION ALL select ‘test’ UNION ALL select ‘tester’ UNION ALL select ‘tester’ ) Select Name, COUNT(name) From temp Group By Name, Cast(name As varbinary(100)) Using a collation: Select Name Collate … Read more

SQL Server: convert ((int)year,(int)month,(int)day) to Datetime [duplicate]

In order to be independent of the language and locale settings, you should use the ISO 8601 YYYYMMDD format – this will work on any SQL Server system with any language and regional setting in effect: SELECT CAST( CAST(year AS VARCHAR(4)) + RIGHT(‘0’ + CAST(month AS VARCHAR(2)), 2) + RIGHT(‘0’ + CAST(day AS VARCHAR(2)), 2) … Read more

tech