When creating a function built on a view, if the view is later removed your function is broken.
By using CREATE FUNCTION .. WITH SCHEMABINDING clause you can protect against these sorts of problems
SCHEMABINDING
Specifies that the function is bound to the database objects that it references. If a function is created with the SCHEMABINDING option, then the database objects that the function references cannot be altered (using the ALTER statement) or dropped (using a DROP statement).
The binding of the function to the objects it references is removed only when one of two actions take place:
The function is dropped.
The function is altered (using the ALTER statement) with the SCHEMABINDING option not specified.
http://msdn.microsoft.com/en-us/library/aa258261(SQL.80).aspx
No comments:
Post a Comment