sqlserver 2008 局域网跨服务器T-SQL操作(二)

--判断是否开启远程操作服务,如果关闭,则开启,用完之后关闭
DECLARE @value SQL_VARIANT
SELECT @value=VALUE from sys.configurations WHERE NAME='show advanced options'
IF(@value=convert(sql_variant,0))
BEGIN
EXEC sp_configure 'show advanced options',1
RECONFIGURE
END
SELECT @value=VALUE from sys.configurations WHERE NAME='Ad Hoc Distributed Queries'
IF(@value=convert(sql_variant,0))
BEGIN
exec sp_configure 'Ad Hoc Distributed Queries',1
RECONFIGURE
END
SELECT * from OpenDataSource('SQLOLEDB','Data Source=192.168.35.6;User ID=sa;Password=server').[Test2.0].dbo.Userinfo --关掉远程操作服务
exec sp_configure 'Ad Hoc Distributed Queries',0
RECONFIGURE
exec sp_configure 'show advanced options',0
RECONFIGURE
上一篇:[UnityShader基础]06.#pragma multi_compile


下一篇:MVC 程序在编译时提示 GAC与 Temporary ASP.NET Files目录内引用文件版本不一致