That's true, I forgot about the ANSI_PADDING setting. As long as SQL Server
doesn't try to do any type of collation conversions on the binary data, he
should be OK with ANSI_PADDING on then?
>> Yes it will break. By definition SQL strips whitespace characters from
>> the end of VARCHARs. As soon as you get an encrypted value like
[quoted text clipped - 24 lines]
> There may still be other reasons for not storing the encrypted binary
> value as a string, though.
> That's true, I forgot about the ANSI_PADDING setting. As long as SQL
> Server doesn't try to do any type of collation conversions on the binary
> data, he should be OK with ANSI_PADDING on then?
I don't know. I can't think of any problems that could lead to data
loss, but I don't feel like putting two fingers on the bible and say
"It will work".
I can see problems for innocent GUIs who think the column has character
data, and then are smacked in the face by a NUL character, but that is
not any major concern.
And, in case it was not clear from my post, ANSI_PADDING OFF is a killer
for encryption also with binary columns.

Signature
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Mike C# - 22 Feb 2008 02:41 GMT
My concern with collation conversion is that I've seen character data
converted to strange codes during the insert process due to code page
conversions. I'm not sure how SQL would handle binary data being cast to
character and inserted/updated into a table ... would it apply similar code
page conversions in some instances? Where most of your character data might
normally be in the range of 0x20 to 0x7f, binary encrypted data will cover
the whole range regularly. I've seen data loss when converting character
data to a different code page, but I don't know that code page conversions
would be a problem with binary to character conversions. I haven't tested
though, and I'm not 100% on how SQL handles binary to character code page
issues, or if it even needs to.
>> That's true, I forgot about the ANSI_PADDING setting. As long as SQL
>> Server doesn't try to do any type of collation conversions on the binary
[quoted text clipped - 10 lines]
> And, in case it was not clear from my post, ANSI_PADDING OFF is a killer
> for encryption also with binary columns.
Erland Sommarskog - 22 Feb 2008 23:00 GMT
> My concern with collation conversion is that I've seen character data
> converted to strange codes during the insert process due to code page
> conversions.
These conversions typically happens in the client API. Say that your
ANSI code page is 1252, but the server collation is Polish_CI_AS which
uses page 1250. In this the letter "ñ" will be converted to "n". (Despite
the fact that the character on that code point in Latin-2, N WITH ACUTE
ACCENT, has exactly the same pronouciation as ñ.)
Note that this does never happen with Unicode data.
> I'm not sure how SQL would handle binary data being cast to character
> and inserted/updated into a table ... would it apply similar code page
> conversions in some instances?
That should definitely not happen my opinion.

Signature
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx