How can I make SQL Server return FALSE for comparing varchars with and without trailing spaces?

From the docs on LEN (Transact-SQL): Returns the number of characters of the specified string expression, excluding trailing blanks. To return the number of bytes used to represent an expression, use the DATALENGTH function Also, from the support page on How SQL Server Compares Strings with Trailing Spaces: SQL Server follows the ANSI/ISO SQL-92 specification … Read more

What is the string length of a GUID?

It depends on how you format the Guid: Guid.NewGuid().ToString() = 36 characters (Hyphenated) outputs: 12345678-1234-1234-1234-123456789abc Guid.NewGuid().ToString(“D”) = 36 characters (Hyphenated, same as ToString()) outputs: 12345678-1234-1234-1234-123456789abc Guid.NewGuid().ToString(“N”) = 32 characters (Digits only) outputs: 12345678123412341234123456789abc Guid.NewGuid().ToString(“B”) = 38 characters (Braces) outputs: {12345678-1234-1234-1234-123456789abc} Guid.NewGuid().ToString(“P”) = 38 characters (Parentheses) outputs: (12345678-1234-1234-1234-123456789abc) Guid.NewGuid().ToString(“X”) = 68 characters (Hexadecimal) outputs: {0x12345678,0x1234,0x1234,{0x12,0x34,0x12,0x34,0x56,0x78,0x9a,0xbc}}

MySQL too long varchar truncation/error setting

You can disable STRICT_TRANS_TABLES and STRICT_ALL_TABLES. This allows the automatic truncation of the inserted string. Quote from MySQL Documentation. Strict mode controls how MySQL handles invalid or missing values in data-change statements such as INSERT or UPDATE. A value can be invalid for several reasons. For example, it might have the wrong data type for … Read more

MySQL varchar index length

Sept 2021 edit: I’ve been using MySQL 8.0 for a couple years now, so here’s some updated info. The MySQL manual now has a very informative page regarding conversion between utf8mb3 (currently also known as utf8) and utf8mb4. utf8mb3 is deprecated and will be removed eventually; and when it is removed, its current alias, utf8, … Read more