Solved

Determine the length of the longest string in a CSV file to figure out the optimal "x" for an NVARCHAR(x)

Posted on 2008-10-03
2
775 Views
Last Modified: 2013-11-25
Hi,

I want to know the best way to see, for each column in a CSV file, what the longest string is in the column. This way we can pick a number of characters that is 20% larger than this for a cushion. I know i could just use an nvarchar(max), but I think this is needlessly wasteful. I know I could do something like this in excel, but I think the best solution would be a little command/script I could run in Powershell or something.

Thanks!
0
Comment
Question by:Dicklestein
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 39

Accepted Solution

by:
BrandonGalderisi earned 50 total points
ID: 22634961
The great thing about nvarchar fields is the VAR.  It's variable.  The actual space used is limited to the actual data on each row.  nvarchar(max) will also stay in the the page if possible.  Only if the data is too big to fit on a page will it not be stored with it.
0
 

Author Comment

by:Dicklestein
ID: 22636986
OK, I understand. Thanks!
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how the fundamental information of how to create a table.

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question