0
|
ljs TheVillageIdiot · 技术社区 · 15 年前 |
1
1
希望我能理解这些问题,但与其删除或更换[服务器],我建议使用以下两种方法之一:
我希望有帮助。 |
2
1
|
3
1
USE master GO SET NOCOUNT ON; -------------------------------------------------------------------- -- Test linked server connections -------------------------------------------------------------------- BEGIN TRY DROP TABLE #Svrs; END TRY BEGIN CATCH END CATCH; CREATE TABLE #Svrs ( [Server] nvarchar(max), [CanConnectAsDefault] bit ); DECLARE @ServerName nvarchar(max), @RetVal int; DECLARE Svrs CURSOR FAST_FORWARD READ_ONLY FOR SELECT ServerName = S.name FROM sys.servers S; OPEN Svrs; FETCH NEXT FROM Svrs INTO @ServerName; WHILE @@FETCH_STATUS = 0 BEGIN BEGIN TRY EXEC @RetVal = sys.sp_testlinkedserver @ServerName; END TRY BEGIN CATCH SET @RetVal = sign(@@error); END CATCH; INSERT INTO #Svrs SELECT @ServerName , CASE WHEN @RetVal = 0 THEN 1 ELSE 0 END; FETCH NEXT FROM Svrs INTO @ServerName; END; CLOSE Svrs; DEALLOCATE Svrs; SELECT * FROM #Svrs DROP TABLE #Svrs; GO -------------------------------------------------------------------- -- Report linked server references -------------------------------------------------------------------- BEGIN TRY DROP TABLE #Refs; END TRY BEGIN CATCH END CATCH; CREATE TABLE #Refs ( [Server] nvarchar(max), [Database] nvarchar(max), [Schema] nvarchar(max), [Object] nvarchar(max), [Type] nvarchar(max) ); DECLARE @DatabaseName nvarchar(max), @ServerName nvarchar(max), @SQL nvarchar(max); DECLARE Refs CURSOR FAST_FORWARD READ_ONLY FOR SELECT DatabaseName = D.name , ServerName = S.name -- , ServerProvider = S.provider -- , ServerSource = S.data_source FROM sys.databases D CROSS JOIN sys.servers S WHERE D.name NOT IN ('master', 'tempdb', 'model', 'msdb', 'ReportServer', 'ReportServerTempDB'); OPEN Refs; FETCH NEXT FROM Refs INTO @DatabaseName, @ServerName; WHILE @@FETCH_STATUS = 0 BEGIN SET @SQL = 'USE [' + @DatabaseName + ']; INSERT INTO #Refs SELECT DISTINCT ''' + @ServerName + ''', ''' + @DatabaseName + ''', S.[name], O.[name], O.type_desc FROM syscomments C INNER JOIN sys.objects O ON C.id = O.[object_id] LEFT JOIN sys.schemas S ON S.[schema_id] = O.[schema_id] WHERE C.[TEXT] LIKE ''%[ ,~[( '''']' + @ServerName + '[ .,~])'''' ]%'' ESCAPE ''~'';' PRINT 'Looking for ' + @ServerName + ' refs in ' + @DatabaseName -- + ': ' + @SQL; EXEC sp_executesql @SQL; FETCH NEXT FROM Refs INTO @DatabaseName, @ServerName; END CLOSE Refs; DEALLOCATE Refs; SELECT * FROM #Refs DROP TABLE #Refs; GO -------------------------------------------------------------------- SET NOCOUNT OFF; GO |
user6748530 · 将动态XML文件加载到树视图控件 6 年前 |
Ishan Khare · Kotlin无法导入包 6 年前 |
H4p7ic · 排序服务总线队列消息 7 年前 |
user3026965 · 导出到时,在文件名中插入时间戳。csv 7 年前 |
user2861089 · 从基因组gbff文件中提取元数据 7 年前 |