sql-serverssmscreate-view

I cannot find my CREATE VIEW table after refreshing even after "Commands completed successfully." message. (SQL)


--Creating View to store data for later visualizations

CREATE VIEW PeopleVaccinatedpercent AS

SELECT dea.continent, dea.location, dea.date, dea.population, vac.new_vaccinations
,SUM(cast(new_vaccinations as bigint)) 
OVER (Partition by dea.location ORDER BY dea.location, dea.date) AS RollingPeopleVaccinated
    FROM PortofolioProject..CovidDeaths dea 
    JOIN PortofolioProject..CovidVaccination vac
    ON dea.location = vac.location
    and dea.date = vac.date
    WHERE dea.continent is not null

Commands completed successfully.

After Refreshing I still don't get any result under Views file on the left


Solution

  • First of all, make sure that you have expanded the correct database in the Object Explorer tree view in the left pane and that the SQL editor window is connected to the correct database. (The editor's current database is displayed in the toolbar, just below the main menu.) Being connected to the wrong database (often the master database) is a regular mistake by myself, anyway.

    You should be aware that the Object Explorer pane is not automatically updated when you make modifications by executing an SQL query or script. You may update the tree view manually by right-clicking the desired node (in your case the Views node) in the tree and clicking Refresh in the context menu.

    Also note the error in the SQL editor, indicated by a red underline. It may be the case that the local IntelliSense cache is corrupted or not updated correctly. You can update it manually. In the main menu, go to Edit->Intellisense->Refresh local cache. Shortly after clicking it, the error message (red underline) should disappear.