2

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?

1 Answer 1

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.

1
  • 1
    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
    Commented Aug 11, 2017 at 13:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .