1

When I try to use Excel 2013 to import External Data from a SQL Server Data Source, it does not import the Guids.

The Query I'm using is:

SELECT * FROM TABLENAME

The table Structure is:

ThingId uniqueidentifier,
ThingName nvarchar(50)

When I explicitly ask Excel to import just the uniqueidentifier, it imports nothing (query):

SELECT ThingId from TABLENAME

How do I get Excel to import Unique Identifiers (GUIDs) when I use the "External Data" feature?

3

Excel (for reasons I have not yet determined), cannot handle imported Guids natively. In order to import GUIDs from SQL Server, you must first change the query to CAST the Guid to an nvarchar. The data source query would change to:

SELECT CAST(ThingID as nvarchar(100)), ThingName from TABLENAME

The CAST function ensures that the GUID is in a format that Excel interprets as text. Any format that outputs text will do; it doesn't have to be nvarchar.

  • I wonder if that's generally true of columns that are stored as byte arrays. You probably can't import binary or varbinary columns either. – tvanfosson Aug 11 '17 at 13:32

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.