日期:2014-05-18  浏览次数:20438 次

写了一个系统函数,删除不掉了。。。
以下内容是看论坛一个帖子学的,我也写了一个类似的,但却修改不了,也删除不掉,这个函数变成 'system_function_schema '的了,大家可以测试一下


可以写一个系统函数,前提是必须以fn_开头:
如:
use   master
go
create   function   fn_Trim(@v   Nvarchar(4000))
returns   Nvarchar(4000)
as
begin
return   ltrim(rtrim(@v))
end
go
exec   sp_configure   'allow   updates ',1
reconfigure   with   override
go
exec   sp_mschangeobjectowner   'fn_Trim ', 'system_function_schema '
go
exec   sp_configure   'allow   updates ',0
reconfigure   with   override

go
--调用
use   northwind
go
select   fn_trim(N 'a   ')--不带用户名




------解决方案--------------------
use master
go
exec sp_configure 'allow updates ',1
reconfigure with override
go
delete sysobjects where name = 'fn_Trim '
------解决方案--------------------
楼主,sp_mschangeobjectowner 这个存储过程在帮助里是没有文档的,你是怎么找出来的?
------解决方案--------------------
要放开修改系统对象的权限
------解决方案--------------------
这是一个未公开的存储过程,帮助里有sp_changeobjectowner 功能一样
------解决方案--------------------
--直接更改sysobjects表uid列为1
exec sp_configure 'allow updates ',1
reconfigure with override
go
update sysobjects set uid = 1 where name = 'Fn_Trim '
go
exec sp_configure 'allow updates ',0
reconfigure with override
--成功删除
drop function Fn_Trim