Hi,

I have data stored in a view in MS SQL Server and I am using ODBC to connect to this database from Stata. However when I'm now trying to access this view, I cant connect through to it and retrieve the data. When I use -odbc query- I can only retrieve a list of tables and none of the views in my database. Does anyone have any success with accessing views from within Stata? The sql code works absolutely fine in SQL Server Management Studio so it is not a case of permissions. I can post more information if it helps

This is my script:
Code:
#delimit ;
odbc load, exec("
SELECT OfficialCode
    , UTLA19CD
    , Age
    , Population Pop
    , Period [Year]
    FROM Populations.dbo.vRes_LSOA11_SingleYear a
     INNER JOIN LookupsShared.dbo.vLKP_LSOA11 b on b.LSOA11CD = a.OfficialCode
        WHERE Sex < 4") dsn(DataSource)
                clear ;

#delimit cr