question

long-5688 avatar image
0 Votes"
long-5688 asked Criszhan-msft commented

Max size of data to be encrypted

Max size of data decrypted by CONVERT(varchar, DecryptByKey(encripted_data)) is only 30?

sql-server-general
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,

CHAR(n) and VARCHAR(n)

When n isn't specified in a data definition or variable declaration statement, the default length is 1. If n isn't specified when using the CAST and CONVERT functions, the default length is 30.


1 Vote 1 ·

1 Answer

ErlandSommarskog avatar image
2 Votes"
ErlandSommarskog answered

Yes. Since you don't specify any length, you get a default of 30. With CONVERT, I should hasten to add. If you say

DECLARE @var varchar

you get varchar(1).

So always specify the length explicitly!

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.