I have a SQL Server and I want to import data from a view into Excel via Microsoft Query.
Sounds easy right? Well it isn’t as some of the columns are of a user-defined data type.
tblSeller:
- ID:
int - Name:
nvarchar(50) - Country:
CountryName:nvarchar(50)
tblBuyer:
- ID:
int - Name:
nvarchar(50) - Country:
CountryName:nvarchar(50)
tblSale:
- ID:
int - SellerId:
int - BuyerId:
int
vSales:
SellerName, SellerCountry, BuyerName, BuyerCountry
(I think you get the idea that I have joined tblSale with tblSeller and tblBuyer and want to get names and countries – and since this is just an example I have left out all other stuff which would make it a useful view!!!)
The view vSales works like a charm on my server: It shows me all my information. The problem occurs when I want to import it into Excel 2010 via “From Microsoft Query” (Data => From Other Sources => From Microsoft Query). All columns with a user-defined data type are not available!
Only if I import data directly via “From SQL Server” (Data => From Other Sources => From SQL Server) I get my data. But as my real view contains hundreds of columns and nearly 200.000 rows that is not and option as I need to specify which columns I want to import.
So to put it short: how to import data from a SQL Server view into Excel using a Microsoft Query in order to be able to limit number of columns?
Sorry for misinforming you… I tried to simplify my question – which also removed the problem!
The definition of the countries was: st_CountryName:nvarchar(50).
And it seems as if Excel is not able to import types where the underscore is a part of the “name”. Sorry for misleading you all in my question – but hope someone else will find this answer helpful!