Home > Uncategorized > SharePoint 2010 – Failed Export : String or binary data would be truncated

SharePoint 2010 – Failed Export : String or binary data would be truncated

When attempting to execute a PS Script to export a Site Collection in SharePoint 2010 (Export-SPWeb) I was receiving the following error in the export log:

Failed Export : String or binary data would be truncated

Having experienced this before I knew this had to do with lengthy URL’s that exceed the 260 length limit threshold within SharePoint.  Even though SharePoint does not warn you when the URLs exceed that threshold it will not allow you to export sites with URL’s longer than that 260 character limit.

To determine where in the Site Collection there might be URL’s longer than the 260 characters limit you can determine this in two different ways.

The supported way via PowerShell, or by taking a backup of your current production database and executing a query on the database to find the URLs and then making changes to those URLs within SharePoint.  I will only show you the supported way via PowerShell.

Utilizing PowerShell to generate a .csv report of SharePoint URLs  with character lengths greater than or equal to 260 characters.

————————————————————————————————————————-

#Get SPSite
$site = Get-SPSite http://portal

#Create .csv file to store URL Length results$URLLengths = “URL `t”  + “Length” >> URLLength.csv

#foreach loop to loop through all webs in a site
foreach ($web in $site.AllWebs)

{
#foreach loop to loop through all lists in the webs
foreach ($list in $web.Lists)
{
#foreach loop to loop through all items in a list
foreach ($item in $list.Items)
{
#Generate item level URL
$url = $web.URL + “/” + $item.URL
#Get URL Length
$urlLength = $url.Length

#If statement to check URL Length.  If greater than or equal to 260 write to .csv file
if ($urlLength -ge 260)

{
$url + “`t” + $urlLength >> $URLLengths
}
}
}
}
$site.dispose()

————————————————————————————————————————

This script will generate a csv file with all the URL’s longer than 260 characters.   You will have to manually go to each URL and physically change the length of the URL before you can export.

Hopefully this helps others that might run into a similiar issue.

 

 

 

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: