Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 320
  • Last Modified:

VARCHAR to MAX or not

Is there a performance penalty for me to use VARCHAR(MAX) versus VARCHAR(3000).  I have an string variable in a SQL stored procedure which will most certain be expanded over time.  Is VARCHAR(MAX) equal to VARCHAR(3000) when it comes to speed and memory usage?
0
Phil5780
Asked:
Phil5780
  • 2
1 Solution
 
Aneesh RetnakaranDatabase AdministratorCommented:
there could be some slight performace issue, dont go for varchar(max) unless the rowsize exceeds 8060 bytes, because the query optimiser considers the length of the field for creating an optimal plan
0
 
Phil5780Author Commented:
The variable in question is central to constructing a dynamic query (via sp_executesql).  Would I be better off dividing out my logic into smaller queries and manipulating data using a temp table?  I've heard temp tables should always be avoided.
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
now i got it, you can go ahaed with varchar(max)
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now