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
766 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
2 Comments
 
LVL 39

Accepted Solution

by:
BrandonGalderisi earned 50 total points
Comment Utility
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
Comment Utility
OK, I understand. Thanks!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now