Msg 319, Level 15, State 1, Line 88 Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.

pruthvi salian 0 Reputation points
2023-03-31T12:41:12.3266667+00:00
Create Table #percentpopulationvaccination
(
continent nvarchar(255),
location nvarchar(255),
date numeric,
population numeric,
New_vaccinations numeric,
rollingpeoplevaccinated numeric,
);

Insert Into #percentpopulationvaccination
select dea.continent, dea.location,dea.date,dea.population,vac.new_vaccinations
,sum(cast(vac.new_vaccinations as int)) OVER (partition by dea.location order by dea.location,dea.date) as rollingpeoplevaccinated
--,((rollingpeoplevaccinated/population)*100) as percentage

from Portfolioproject..coviddeaths dea
join  Portfolioproject..covidvaccinations vac
	on dea.location = vac.location
	and dea.date = vac.date 
where --dea.location like '%albania%' --and
 dea.continent is not null

 select*, (rollingpeoplevaccinated/population)*100 as percentage
from #percentpopulationvaccination

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,850 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,462 questions
{count} votes

2 answers

Sort by: Most helpful
  1. CosmogHong-MSFT 23,556 Reputation points Microsoft Vendor
    2023-04-03T02:07:23.77+00:00

    Hi @pruthvi salian

    This error message indicates that you need to add semicolon; before the keyword 'with'.

    Please check your code carefully, cause the query you post don't contain the keyword 'with'.

    Best regards,

    Cosmog Hong


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Sahil 0 Reputation points
    2024-05-13T06:18:08.44+00:00

    I was getting the same error but it was due to the use of openjson in sql query .Contains method in the newer version of EF Core translates to openjson to increase efficiency but it is not supported by the older versions of some databases. And if you dont want to shift to the newer database version you can use these options :

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)

    => optionsBuilder

    .UseSqlServer(@"<CONNECTION STRING>", o => o.UseCompatibilityLevel(120));

    You can refer this document : https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-8.0/breaking-changes

    0 comments No comments