Skip to content

Instantly share code, notes, and snippets.

@yorek
Created April 28, 2020 23:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yorek/d1664f8e5508c6c10c90f4f9a5b247b7 to your computer and use it in GitHub Desktop.
Save yorek/d1664f8e5508c6c10c90f4f9a5b247b7 to your computer and use it in GitHub Desktop.
Azure SQL UDF and Persisted Columns
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