Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jonoling
Frequent Visitor

SQL Tables importing without associated data types

Hi,

 

I have a fact table that I'm connecting to in SQL. When reviewing the INFORMATION_SCHEMA.COLUMNS query in SSMS for the table it shows the [order_date] field as being stored as a datetime data type which is correct:

jonoling_0-1616619798895.png

 

However when importing this table into PBI Desktop all the datatypes are changed to Text in transit:

2021-03-25_10-05-09.png

 

The only steps in the query are:

let
Source = Sql.Database(sqlserver, db)
Table = Source{[Schema="dbo",Item=tablename]}[Data]
in
Table
 

I can convert the data types manually in Power Query but this prevents incremental refresh if we have to download the entire dataset, change types and then filter.

 

Have had a search around but couldn't find any reasons as to why this would occur. Would welcome ideas as to why this is happening, and how to resolve.

 

Thanks Power BI Community!

 

1 ACCEPTED SOLUTION

None, it's the out of the box SQL Server connector from Power Query. The only inputs it's taking is the SQL string and DB, then navigating to the table in question. 

 

let
Source = Sql.Database(sqlserver, db)
Table = Source{[Schema="dbo",Item=tablename]}[Data]
in
Table

 Agree, it doesn't seem to be a widespread issue, this is the first time I've come across an issue like this. Just tested with a sandbox WorldWideImporters DB and the native query generated brings through datatypes fine. 

jonoling_0-1617062684862.png

 

Odd!

View solution in original post

6 REPLIES 6
UThomas
New Member

Hello, I have the same issue with a MS SQL Database. There are a custom data type called (APdate) which is a datetime-Type, but PowerQuery didn't recognize it as datetime but set it to text.

 

I use the standard "From MS SQL Database"-Connector.

let
    Quelle = Sql.Databases("SQL1.xxx.de"),
    xxx = Quelle{[Name="xxx"]}[Data],
    dbo_yyy = xxx{[Schema="dbo",Item="LIEFRECHNUNG"]}[Data]
in
    dbo_LIEFRECHNUNG
select [$Table].[id] as [id],
    [$Table].[timestamp] as [timestamp],
    [$Table].[LIEFRECHNUNG] as [LIEFRECHNUNG],
    [$Table].[STATUS] as [STATUS],
    [$Table].[ADRESSE] as [ADRESSE],
    [$Table].[PERSONAL] as [PERSONAL],
    convert(nvarchar(max), [$Table].[RECHNUNGSDATUM]) as [RECHNUNGSDATUM],
    [$Table].[RECHNUNGSNR] as [RECHNUNGSNR],
    convert(nvarchar(max), [$Table].[DATUM]) as [DATUM],

 

if I change the M-code to:

 

let
    Quelle = Sql.Database("SQL1.xxx.de", "yyy", [Query="SELECT * from LIEFRECHNUNG"])
in
    Quelle

the columns typ is correct (datetime).

 

What's wrong with the first (out-of-the-box) M-Code?

Why isn't PowerQuery using the system data type from SQL-Server?

lbendlin
Super User
Super User

Anything suspicious on the Fiddler or Power Query Diagnostics?

lbendlin
Super User
Super User

which options parameters did you apply to your connector?  If this were a widespread problem we'd have heard about it by now.

None, it's the out of the box SQL Server connector from Power Query. The only inputs it's taking is the SQL string and DB, then navigating to the table in question. 

 

let
Source = Sql.Database(sqlserver, db)
Table = Source{[Schema="dbo",Item=tablename]}[Data]
in
Table

 Agree, it doesn't seem to be a widespread issue, this is the first time I've come across an issue like this. Just tested with a sandbox WorldWideImporters DB and the native query generated brings through datatypes fine. 

jonoling_0-1617062684862.png

 

Odd!

lbendlin
Super User
Super User

Run a fiddler trace and also check the query logs on your SQL server.  Maybe something is blocking the meta data calls?

 

 

Looks like the issue is with the Power BI SQL Connector itself. Looking at the native query being sent, all fields are being converted to text data types:

jonoling_1-1617058924760.png

Writing a custom SQL statement to select the data seems to bring across the right datatypes. I haven't come across documentation on why this occurs and how to turn it off yet though.

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.