Sequence Contains No Elements

I came across this “Sequence contains no elements” error when using Always Encrypted a while back and wanted to write a quick post. In this case, I was trying to encrypted a computed column. Here’s the underlying error message:

Sequence contains no elements

The full list of supported columns are found here. I can clearly see ‘Computed columns’ as not supported. But the message implies that I may be trying to encrypt a sequence. So, it is misleading. My guess is that “sequence contains no elements” is a Visual Studio error message that is bubbling up, and not anything related to a sequence object inside of the database.

SQL Server Management Studio (SSMS) has the ability to block columns from being selected for the encryption operations. You can see an example of that here:

If you hover over the red icon you get metadata about why the column is not selectable. It would be useful if SSMS also filtered out computed columns, so a user avoids the same mistake I made.

I’ve written before about the importance of being able to show someone the error. In this case, I was able to see the error, but did not understand what was being communicated. I spent time looking in the wrong places before I understood that the message was misleading. Here’s hoping this post saves the next person some time.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.