转繁体 sp_oacreate
use master
go
create function DCMSconvert (@sInText Nvarchar(4000),@TransType int)
--注释:1、@sInText 表示要转换的字符串 2、@TransType 表示转换类型 0转繁体 1-转简体
RETURNS Nvarchar(4000)
AS
BEGIN
DECLARE @sOutText Nvarchar(4000)
DECLARE @Document int
EXEC sp_OACreate 'Word.Document', @Document OUT
EXEC sp_OASetProperty @Document, 'Application.Selection.Text', @sInText
EXEC sp_OAMethod @Document,'Application.Selection.Range.TCSCConverter',NULL,@TransType,1,1
EXEC sp_OAGetProperty @Document, 'Application.Selection.Text', @sOutText OUT
EXEC sp_OADestroy @Document
EXEC sp_OAStop
RETURN(@sOutText)
END
GO
--调用例程一、
use Northwind
select master.dbo.DCMSconvert('首页是交流思想的地方',0)
go
create function DCMSconvert (@sInText Nvarchar(4000),@TransType int)
--注释:1、@sInText 表示要转换的字符串 2、@TransType 表示转换类型 0转繁体 1-转简体
RETURNS Nvarchar(4000)
AS
BEGIN
DECLARE @sOutText Nvarchar(4000)
DECLARE @Document int
EXEC sp_OACreate 'Word.Document', @Document OUT
EXEC sp_OASetProperty @Document, 'Application.Selection.Text', @sInText
EXEC sp_OAMethod @Document,'Application.Selection.Range.TCSCConverter',NULL,@TransType,1,1
EXEC sp_OAGetProperty @Document, 'Application.Selection.Text', @sOutText OUT
EXEC sp_OADestroy @Document
EXEC sp_OAStop
RETURN(@sOutText)
END
GO
--调用例程一、
use Northwind
select master.dbo.DCMSconvert('首页是交流思想的地方',0)