SQLSEVER2005中找不到存储过程xp_getfiledetails 解决办法

当在sqlserver2005中使用"存储过程xp_getfiledetails "时,会报找不到该存储过程的错误。

原因是该存储过程在sqlserver2000的版本存在,而在2005中已经不存在。用以下方法可以解决该问题,相当于重新写了一个csp_getfiledetails的存储过程替代原来的xp_getfiledetails存储过程。

在C盘下,新建Temp文件夹,放Conchango.SqlServer.SqlClrToolkit.GetFileDetails.dll文件到里面。再在跑下下面的sql脚本:

 

Code
Code
--I'm creating it in master. You may wish to put it somewhere else
USE    master
GO

--Enable clr on your server
--
 WITH OVERRIDE forces the change that conflicts with the IO affinity mask
sp_configure 'clr enabled'1
reconfigure with override

--Enable assemblies with PERMISSION_SET=EXTERNAL_ACCESS 
--
 to be cataloged in the database
ALTER DATABASE master SET trustworthy ON



--Drop the assembly if it exists already
IF    EXISTS (SELECT * FROM sys.procedures WHERE name = 'csp_getfiledetails')
    
DROP PROCEDURE csp_getfiledetails
GO
--Drop the procedure if it exists already
IF    EXISTS (SELECT * FROM sys.assemblies WHERE name = 'Conchango.SqlServer.SqlClrToolkit.GetFileDetails')
    
DROP ASSEMBLY [Conchango.SqlServer.SqlClrToolkit.GetFileDetails]
GO

--Catalog the assembly with PERMISSION_SET=EXTERNAL_ACCESS.
--
 This permission set is required because the sproc accesses an external resource (i.e. a file)
--
 Script assumes you have saved the assembly to c:\temp, local to SQL Server
CREATE    ASSEMBLY [Conchango.SqlServer.SqlClrToolkit.GetFileDetails]
FROM    'C:\Temp\Conchango.SqlServer.SqlClrToolkit.GetFileDetails.dll'
WITH    PERMISSION_SET = EXTERNAL_ACCESS
GO

--Have a look at the assembly within the database
--
 At this stage the assembly can be deleted from the file system
SELECT * FROM sys.assemblies
SELECT * FROM sys.assembly_files
GO

--Create our procedure from the assembly
CREATE    PROCEDURE dbo.csp_getfiledetails( @pFileName nvarchar(4000) )
AS    EXTERNAL NAME [Conchango.SqlServer.SqlClrToolkit.GetFileDetails].[Conchango.SqlServer.SqlClrToolkit.GetFileDetails].csp_getfiledetails

--Run it!!!!!
csp_getfiledetails 'c:\boot.ini'

 

Conchango.SqlServer.SqlClrToolkit.GetFileDetails.dll 下载

posted @ 2009-04-21 16:20  chunchill  阅读(1405)  评论(3编辑  收藏  举报