Question

I'm trying to perform an upgrade to SP2 on Sharepoint 2010. However during the final stages of the upgrade process, it fails. Digging into the upgrade logs I see this error as the reason:

Column, parameter, or variable #2: Cannot find data type tvpProfileExportItems.
Must declare the table variable "@Items".
Parameter or variable '@Items' has an invalid data type.

I have no idea how to fix this and I can't delete / recreate the database as it had production data in it.

Does anyone have any ideas or suggestions on how to get around this?!

Thanks!

Was it helpful?

Solution

I finally sorted this issue. I ended up ringing MS on it and their only official supported fix was to delete and recreate the User Profile Service Application & it's database. However this was on our production server and I couldn't do that. Luckily based on their information I was able to come up with an unofficial fix.

The error happens because somehow the user profile database is missing datatypes & stored procedures it should contain. So my fix for this was to provision a new user profile service application with a new database, export the datatypes & stored procedures from it and import them into my existing database. The upgrade then ran successfully.

Step 0 - Backup your sharepoint server & database!!

Step 1 - Create a new user profile service application

  • Log on to central administration
  • Go to Application Management > Manage service applications
  • New > User Profile Service Application
  • Set it up with a name "UPA Temp" and new databases, for this example I'll use "Profile DB Temp", "Social DB Temp" and "Sync DB Temp"
  • Click create (Note: I had to go in and add my farm account as sysadmin for this to work - I got an error about the master db)

Step 2 - Export the stored procedures & data types

  • Open SQL management studio on your sharepoint database server
  • Log on to your sharepoint instance and find the newly created user profile database - "Profile DB Temp" in my example
  • Verify it has the datatype 'tvpProfileExportItems' by expanding the database, Programmability > Types > User-Defined Table Types. You should see 'dbo.tvpProfileExportItems'
  • Verify it has the stored procedure 'profile_ADImportAddFailedItems' by expanding the database, Programmability > Stored Procedures. You should see 'dbo.profile_ADImportAddFailedItems' in the list.
  • Export the datatype by right-clicking the database, going to Tasks > Generate Scripts
  • Under 'Choose Objects', select specific database objects and select 'User-Defined Table Types'. Click Next and save the script as 'profile_datatypes.sql'
  • Export the stored proceedures by right-clicking the database, going to Tasks > Generate Scripts
  • Under 'Choose Objects', select specific database objects and select 'Stored Procedures'. Click Next and save the script as 'profile_procedures.sql'

Step 3 - Delete the temporary User Profile Service Application

  • We no longer need the temporary application we created in Step 1, so log into Central Administration
  • Go to Application Management > Manage service applications
  • Find the "UPA Temp" application you created in step 1, select it and delete it. Check the box to delete data associated with this application. MAKE SURE YOU DELETE THE TEMPORARY ONE, NOT YOUR LIVE ONE!

Step 4 - Import the datatype & procedures into your existing User Profile database

  • Open SQL management studio on your sharepoint database server
  • Log on to the sharepoint instance
  • File > Open > File and open 'profile_datatypes.sql' you saved in Step 2
  • At the top of the file it will say 'Use [Profile DB Temp]' or whatever you called your temporary database. Change this to your live profile database
  • Execute the script (F5). It should complete successfully
  • Close that file and then File > Open > File and open 'profile_procedures.sql' you saved in Step 2
  • At the top of the file it will say 'Use [Profile DB Temp]' or whatever you called your temporary database. Change this to your live profile database
  • Execute the script (F5). You will get a bunch of warnings about procedures already existing. This is fine, it'll create any that were missing.

Step 5 - Run the update again

  • That should be it - your User Profile Service Application now has the datatypes & stored procedures it was missing and any cumulative updates should complete successfully!

Best of luck anyone that attempts this!

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top