Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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