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
773 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

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

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

Suggested Solutions

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

759 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