sql server 2008 - Schema Binding with Computed Column Function -
sql server 2008 - Schema Binding with Computed Column Function -
i have table tablea
computed column fielda
bound function returns float. function getfielda
calls 2 sub functions.
i have view includes getfielda
function not computed column value field. tried add together index view said required getfielda
schema bound in order have index on it, changed schema bound (which involved removing computed column) when went seek readd computed column said in order utilize getfielda
schema bound must removed.
is there way have computed column schema bound function or need rework how im getting field in order able have view index?
it's impossible add together index on computed column, unless it's deterministic.
"deterministic functions homecoming same result time called specific set of input values , given same state of database. nondeterministic functions may homecoming different results each time called specific set of input values if database state access remains same."
creating indexes on computed columns user-defined function design guidelinesexample:
create function dbo.funca() returns [float] schemabinding -- required alternative begin homecoming 1.0 -- db engine parses body, , marks func. 'deterministic' end go create table tablea ( k int primary key clustered, dbo.funca() persisted -- must persisted ) go create view viewa schemabinding -- required alternative select k, dbo.tablea go create unique clustered index idx1 on dbo.viewa (k, a) go
you have specify persisted
imprecise info types [real]
, [float]
, in other case can freely create index on view computed column ([decimal] ok).
sql-server-2008
Comments
Post a Comment