Which SQL data type to store Base64 encoded file?

后端 未结 1 1927
半阙折子戏
半阙折子戏 2020-12-30 18:52

nvarchar(max), varchar(max), or should I really decode the string and put it in an image or blob or something?

The longer version : (with all the juicy details)

相关标签:
1条回答
  • 2020-12-30 19:18

    Well, Base64 is a ASCII encoding, really - so definitely no need for NVARCHAR - and since it's text, I'd suggest VARCHAR(MAX)

    It's pure text, up to 2 GB (should be enough), and it's a string-type, so you can use all string functions on it. NVARCHAR does indeed use twice as much storage - always 2 bytes per character - and is totally unnecessary in this case.

    0 讨论(0)
提交回复
热议问题