Any hidden pitfalls changing a column from varchar(8000) to varchar(max)?

后端 未结 3 2061

I have a lot (over a thousand places) of legacy T-SQL code that only makes INSERTs into a varchar(8000) column in a utility table. Our ne

相关标签:
3条回答
  • 2021-02-20 12:35
    • All MAX types have a small performance penalty, see Performance comparison of varchar(max) vs. varchar(N).
    • If your maintenance include online operations (online index rebuild), you will lose the possibility to do them. Online operations are not supported for tables with BLOB columns:
      • Clustered indexes must be created, rebuilt, or dropped offline when the underlying table contains large object (LOB) data types: image, ntext, text, varchar(max), nvarchar(max), varbinary(max), and xml.
      • Nonunique nonclustered indexes can be created online when the table contains LOB data types but none of these columns are used in the index definition as either key or nonkey (included) columns. Nonclustered indexes defined with LOB data type columns must be created or rebuilt offline.

    The performance penalty is really small, so I wouldn't worry about it. The loss of ability to do online rebuilds may be problematic for really hot must-be-online operations tables. Unless online operations are a must, I'd vote to go for it and change it to MAX.

    0 讨论(0)
  • 2021-02-20 12:40

    If you genuinely don't need indexes and it is a large column you should be fine. Varchar (max) appears to be exactly what you need and you will have less problems with existing code than you would if you used text.

    Make sure to test any updates where text is added to the existing text. It should work using regular concatenation, but I'd want to be able to prove it.

    0 讨论(0)
  • 2021-02-20 12:44

    Crystal Reports 12 (and other versions, as far as I know) doesn't handle varchar(max) properly and interprets it as varchar(255) which leads to truncated data in reports.

    So if you're using Crystal Reports, thats a disadvantage to varchar(max). Or a disadvantage to using Crystal, to be precise.

    See:
    http://www.crystalreportsbook.com/Forum/forum_posts.asp?TID=5843&PID=17503
    http://michaeltbeeitprof.blogspot.com/2010/05/crystal-xi-and-varcharmax-aka-memo.html

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