Posts

Unable to begin a distributed transaction

Image
Hey All, I am trying to get a list of error messages on a server using the sp_readlogerror stored procedure. I have a central server A and I am trying to get the information from Server B. exec [server B].model.sys.sp_readerrorlog the above statement works well and gets the data, But it throws up a transaction error when i try to insert into a temp table on server A. Here is the code running on server A: create table #ErrorLog(LogDate datetime, ProcessorInfo varchar(1000),Text varchar(5000)) insert into #errorLog exec [Server B].model.sys.sp_readerrorlog this Throws up a transaction error as below OLE DB provider "SQLNCLI" for linked server "BHSF-BTR-W318" returned message "The partner transaction manager has disabled its support for remote/network transactions.". Msg 7391, Level 16, State 2, Line 3 The operation could not be performed because OLE DB provider "SQLNCLI" for linked server "BHSF-BTR-W318" was ...

Interesting article - A Merge bug

Hey Guys, I have come across a very interesting article by one of the members (Paul White)  of the SQLServerCentral group. Here is the Link to that:   http://sqlblog.com/blogs/paul_white/archive/2010/08/04/another-interesting-merge-bug.aspx have Fun....

Script to find unused tables on a server

/*This Script is used to list all the Unused tables on a Server. The script does not work for the sql 2000 Server*/ declare @sql varchar(2000), @DatabaseName varchar(100) /* LOOP THROUGH THE SERVERS*/ If Object_ID('tempdb..#unusedTables') is not null drop table #unusedTables create table #unusedTables(DatabaseName varchar(100), Object_Id int, TableName varchar(100))    /*CURSES THROUGH ALL THE DATABASES ON THE SERVER  */     declare Database_list cursor for         select     name from     sys.databases where     name not in ('master','msdb','modeL','tempdb')     open Database_list fetch next from Database_list into @DatabaseName while @@fetch_status = 0 begin      /* THIS PART GETS THE LIST OF TABLES IN A PARTICULAR DATABASE*/         set @sql =    'select   ...

Useful Code for Timesheet Reminder

USE [MTSC] GO /****** Object:  StoredProcedure [dbo].[TimesheetHoursDailyReminder]    Script Date: 11/03/2010 13:28:48 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER Procedure [dbo].[TimesheetHoursDailyReminder] AS /******************************************************************************** Stored Procedure Name:    [dbo].[TimesheetHoursDailyReminder] Date Written:             10/06/09            Author:                    Chitanya Chitturi Project/System:            MTSC                Purpose/Description:    Time Sheet Reminder Input Parameters:        Tables:       ...

Script to find the failed jobs on all the servers

/*FINAL CODE*/ declare @servername varchar(200), @sql varchar(2000) /* LOOP THROUGH THE SERVERS*/ if object_id('tempdb..#failedjobs') is not NULL drop table #failedjobs create table #failedjobs (servername varchar(200), jobname varchar(500)) declare server_list cursor for select     servername from     dbo.servers where     enabled =1     and retired = '9999-12-31 00:00:00.000'     open server_list fetch next from server_list into @servername while @@fetch_status = 0     begin         set @sql =    'select                     jh.server as server_name,                     sj.name job_name                 from  ...

Report for Server Activity

USE [rmsprod] GO /****** Object:  StoredProcedure [rms].[PROC_SERVER_ACTIVITY]    Script Date: 10/19/2010 15:39:16 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [rms].[PROC_SERVER_ACTIVITY] AS BEGIN /***************************************************************************************** Stored Procedure Name:   [dbo].[SERVER_ACTIVITY] Date Written:            AUGUST 2010 Author: CHITANYA CHITTURI                                   Project/System:                                                       Purpose/Description:     Input Parameters:     Output Parameters:                 ...

How to identify which process updated a table

CREATE TABLE YourLogTable(ModificationTime DATETIME, [Application] NVARCHAR(500), [SQL] NVARCHAR(MAX)) GO CREATE TRIGGER [dbo].[trgUpdateLogger] ON [dbo].[YourTable] FOR INSERT,UPDATE,DELETE AS --Get updating process info CREATE TABLE #s(EventType VARCHAR(30), Parameters INT, SQL NVARCHAR(MAX)) INSERT INTO #s EXEC('DBCC INPUTBUFFER(@@SPID) WITH NO_INFOMSGS') --Write to log table INSERT INTO YourLogTable (ModificationTime, [Application], [SQL]) SELECT GETDATE(), APP_NAME(), #s.SQL FROM #s --Cleanup DROP TABLE #s GO Note: I found it on LinkedIN... thought it might be useful