A while ago, I worked on a project with one of my developers that required building a web part to display the results from a SharePoint survey in a different manner. The survey itself was a self-assessment… it was composed of 13 questions with approximately five options under each question, and the answers were the ‘Rating Scale’ type. Below is an example of the survey:

While SharePoint does provide basic reporting out of the box, it never turns out to be what the client needs. Because of this, a custom web part was built that allowed an administrator to look at the survey results in a variety of ways – by User – with a drill down to the individual Questions, or Summarized – with a drill down to individual questions & users. An example of the summarized results view by question appears below:

So now I’ve shown off the cool stuff. Before I go any further, I would like to thank Josh Carlisle for his assistance on this – without it, this post wouldn’t exist. Now – the reason I’m really writing this post is because I’ve seen questions asked in the past, and I figured I could lend a bit of a hand with Josh’s guidance… the questions were usually…
“How do I find the survey results in the SharePoint database?”
“Where in SQL are the SharePoint survey answers stored?”
And my first reaction is one of caution… from the mouth of Microsoft…
Warning Modifying the database schema or database structures is not supported. Changes that you make to the database contents may be overwritten when you install updates or service packs for Windows SharePoint Services, or when you upgrade an installation to the next product version.
Okay you say – you understand… and you want to go forward with finding the results data… well, let’s do it! I’m running SPS 2003 on SQL 2005, so my screen shots are from the SQL 2005 Management Studio – but you can do everything in the SQL Clients Tools in 2000 as well.
- First, you need to crack open the Content Database of the portal which contains the survey and open up the Lists table.

- I would recommend you expand the width of the tp_ID & tp_Title columns to make your life a bit easier.
- Now, scroll through the tp_Title columns until you find the name of the survey you are looking for. In my example, I’m looking for the ‘Horizons Self Assessment’.

- Once you’ve found the survey name in the tp_Title column, look at the tp_ID – copy & paste or jot down the ID of the survey.
- Now, open up the UserData table and expand the width of the tp_ListID column.

- You’ve got some digging to do now. You now need to scroll through this table and find the ID that you wrote down before in the tp_ListID column. Note: If the survey has been completed multiple times, then the ID will show up multiple times in the tp_ListId column (Each survey submission represents one record in the table). In my example, I’m looking for the ID of ‘595665fc-6c09-424a-964d-d137b3db5a30’.
- I don’t have SQL 2000 Client Tools in front of me (although I know this can be done), but in the SQL 2005 Management Studio, I don’t have to dig to find the ID. I can just right click on the column, choose Pane -> Criteria. Then, in the second row up top under Column, select the tp_ListID. In the Filter column for that row, copy the ID in. Then execute this query – and you’ve got all of your survey results right in front of you. The following image shows an example of the query & results:

- Or, feel free to use the following query:
SELECT *
FROM UserData
WHERE tp_ListId = ‘unique identifier here’
- I don’t have SQL 2000 Client Tools in front of me (although I know this can be done), but in the SQL 2005 Management Studio, I don’t have to dig to find the ID. I can just right click on the column, choose Pane -> Criteria. Then, in the second row up top under Column, select the tp_ListID. In the Filter column for that row, copy the ID in. Then execute this query – and you’ve got all of your survey results right in front of you. The following image shows an example of the query & results:
- So you’ve found the rows that contain your survey results – should be no problem pulling out the results now, right? Well, not exactly. Depending on the types of questions you are asking in your survey, that dictates how ‘cleanly’ SharePoint stores the results. So the easiest way to start out is to scroll through the columns to your right, and you will see the survey results stored for that particular response. In my example, using all Rating Scale questions, all of the survey results are stored in the ntextX columns, where X is equal to a number. This is a real pain, as Rating Scale questions each get their own ntextX column, but then each Option & answer pair for that question is dumped into the single column that then needs to be parsed. So, let’s take an example:
- My survey has one Rating Scale question about ‘Time Management’, and there are 6 options that the user can rate under this question.

- Now, once this is stored in the database, it appears for me in the following format in the ntextX column:
Establishes satifactory work-life balance.;#+4#Prioritises workload and conflicting demands to achieve key results.;#+4#Organises self and others to meet deadlines.;#+3#Delegates work to achieve optimum overall performance.;#+3#Challenges and improves upon processes which waste time.;#+4#Reduces the impact of distractions upon self and others.;#+3#
-
So now, in order to use this data, I would have to parse it. But obviously, the data is there and available for you if you need to work with it.
- My survey has one Rating Scale question about ‘Time Management’, and there are 6 options that the user can rate under this question.
Finally, just a quick reference guide for you. I’ve done some research, and I’ve found that the different types of survey answers are stored in different columns… this is a summary of my findings.
| TYPE OF ANSWER | COLUMN NAME |
| Single line of text | nvarchar |
| Multiple lines of text | nvarchar |
| Choice | nvarchar |
| Rating Scale | ntext |
| Number | float |
| Currency | float |
| Date & Time | datetime |
| Lookup | int |
| Yes / No | bit |
And if you are interested in the database schema, you can always check out:

