Created
April 28, 2020 23:25
-
-
Save yorek/d1664f8e5508c6c10c90f4f9a5b247b7 to your computer and use it in GitHub Desktop.
Azure SQL UDF and Persisted Columns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create or alter function dbo.CalculateSum(@a as int, @b as int) | |
returns int | |
with schemabinding | |
as | |
begin | |
return @a + @b | |
end | |
go | |
create table dbo.WithPersistedUDF | |
( | |
a int not null, | |
b int not null, | |
s as dbo.CalculateSum(a,b) persisted | |
) | |
go | |
insert into dbo.WithPersistedUDF (a,b) | |
values (10,5), (8,3) | |
go | |
select * from dbo.WithPersistedUDF | |
go |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment