SQLTeam.com | Weblogs | Forums

Why is this simple running total script erroring?

I'm about to throw this pc out of the window - it runs fine on my home pc but won't run on my work pc.

Both versions of SSMS are v18.6.

Error message:

Msg 102, Level 15, State 1, Line 38
Incorrect syntax near 'ORDER'
DECLARE @test AS TABLE
(
Yr INT,
Period INT,
Volume INT
)
INSERT INTO @test
VALUES 
(
'2019', '4', '75'
)
INSERT INTO @test
VALUES 
(
'2019', '5', '75'
)
INSERT INTO @test
VALUES 
(
'2019', '6', '75'
)
INSERT INTO @test
VALUES 
(
'2019', '7', '75'
)
INSERT INTO @test
VALUES 
(
'2019', '8', '75'
)
INSERT INTO @test
VALUES 
(
'2019', '9', '75'
)

SELECT Yr, Period, Volume, SUM (Volume) OVER (ORDER BY Yr, Period) FROM @test 

its working fine for me ..

my SSMS 18.6

1 Like

the reasons

.. something you typed

.. or copy paste special characters

.. or notepad copy the copy from notepad

1 Like

what version of SQL Server

my SQL Server version
Microsoft SQL Server 2017 (RTM) - 14.0.1000.169 (X64) Aug 22 2017 17:04:49 Copyright (C) 2017 Microsoft Corporation Developer Edition (64-bit) on Windows 10 Pro 10.0 (Build 18362: )

1 Like

Nothing copied and pasted - it's typed in on both pcs.

That's what I don't understand, SSMS version 15.0.18338.0 on both devices?!

Ok, SQL Server is 10.5.0 on my work pc, I think that doesn't support this syntax.

Thanks for the responses!