skip to Main Content

I’m getting an error when creating a table. can anyone tell me what I’m doing wrong ?


DROP Table if exists #PercentPopulationVaccinated
Create Table #PercentPopulationVaccinated
(
    Continent nvarchar(255),
    Location nvarchar(255),
    Date datetime,
    Population numeric,
    New_vaccinations numeric,
    RollingPeopleVaccinated numeric
)

2

Answers


  1. You are using a syntax for Microsoft SQL Server instead of Google BigQuery. Here is an adjusted syntax for Google BigQuery:

    CREATE OR REPLACE TABLE PercentPopulationVaccinated
    (
        Continent STRING,
        Location STRING,
        Date DATE,
        Population FLOAT64,
        New_vaccinations FLOAT64,
        RollingPeopleVaccinated FLOAT64
    )
    
    Login or Signup to reply.
  2. You have a few issues with your syntax. I’d highly recommend reviewing the DDL Docs when you have a moment.

    1. BigQuery does not use # as a table prefix. Additionally, it’s best practice to explicitly list the dataset you’re creating the table in:

    CREATE TABLE my-dataset.PercentPopulationVaccinated

    1. You need to use ; to separate each of the unique DDL statements. Alternately, you can combine the two with the OR REPLACE operator:
    DROP Table if exists my-dataset.PercentPopulationVaccinated;
    CREATE TABLE my-dataset.PercentPopulationVaccinated...
    

    OR

    CREATE OR REPLACE TABLE my-dataset.PercentPopulationVaccinated...
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search