Skip to content

Instantly share code, notes, and snippets.

@BrentOzar
Created July 6, 2020 18:19
Show Gist options
  • Save BrentOzar/ec93d1d3bab8cc046d80d8b71ec6442a to your computer and use it in GitHub Desktop.
Save BrentOzar/ec93d1d3bab8cc046d80d8b71ec6442a to your computer and use it in GitHub Desktop.
ALTER DATABASE CURRENT SET COMPATIBILITY_LEVEL = 140;
GO
CREATE OR ALTER FUNCTION dbo.Test()
RETURNS INT AS
BEGIN
DECLARE @i BIGINT;
SELECT TOP 1 @i = CHECKSUM(*)
FROM master.dbo.spt_values;
RETURN 1;
END
GO
SELECT dbo.Test(); /* Works fine */
ALTER DATABASE CURRENT SET COMPATIBILITY_LEVEL = 150;
GO
SELECT dbo.Test();
/* Gets error:
Msg 1789, Level 16, State 1, Procedure Test, Line 6 [Batch Start Line 17]
Cannot use CHECKSUM(*) in a computed column, constraint, default definition, or INSERT statement.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment