跟小D每日学口语

Save MSSQL assembly to DLL

EXECUTE SP_CONFIGURE 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
GO

EXEC sp_configure
'Ole Automation Procedures', 1;
RECONFIGURE WITH OVERRIDE
GO

DECLARE
@IMG_PATH VARBINARY(MAX)
DECLARE
@ObjectToken INT

SELECT
@IMG_PATH = content FROM sys.assembly_files WHERE assembly_id = 65546

EXEC sp_OACreate
'ADODB.Stream', @ObjectToken OUTPUT
        EXEC sp_OASetProperty
@ObjectToken, 'Type', 1
        EXEC sp_OAMethod
@ObjectToken, 'Open'
        EXEC sp_OAMethod
@ObjectToken, 'Write', NULL, @IMG_PATH
        EXEC sp_OAMethod
@ObjectToken, 'SaveToFile', NULL, 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\myassembly.dll', 2
        EXEC sp_OAMethod
@ObjectToken, 'Close'
        EXEC sp_OADestroy
@ObjectToken  

EXEC sp_configure
'Ole Automation Procedures', 0;
RECONFIGURE WITH OVERRIDE
GO

EXECUTE SP_CONFIGURE
'show advanced options', 0
RECONFIGURE WITH OVERRIDE
GO

from: http://stackoverflow.com/questions/4103406/extracting-a-net-assembly-from-sql-server-2005
posted @ 2012-01-31 14:12  javak  阅读(294)  评论(0编辑  收藏  举报