开发者

Are there any possible issues when converting a multi-statment table valued function to an inline table valued function?

We have a lot of multi-statement TVFs and we sometimes want to convert these to be inline TVFs (usually for performance reasons).

We can't do a simple ALTER FUNCTION to make this switch because SQL Server tells us "Cannot perform alter on 'db.FOO' because it is an incompatible object type." so we have to drop the function first and then recreate it.

This has worked well for us, but we aren't sure why SQL Server doesn't just do the drop/create automatically. Is there some particular issue that it's trying to protect us from that we're blindly walking in to?

Some Google searching reveals peop开发者_运维知识库le getting the error message and being told to just drop it and recreate it, but I haven't been able to figure out the why of the error message in the first place.

Any insight into the internals would be appreciated.


They are 2 different kinds of objects in sys.objects thus are not compatible.

Effectively, it is the same as

CREATE TABLE dbo.foo (...)

then

ALTER VIEW dbo.foo ...

A view and a table can be used the same way but they are not the same. Same for TVFs.

There should be different flavours of CREATE FUNCTION for the 3 types...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜