SansSQL

Wednesday, June 30, 2010

MyWindowsClub.com - Another Good website from DotNetSpider.com

MyWindowsClub.com is a new website launched from the famous DotNetSpider.com.

This website provides a room for discussion on most of the major technologies. Even SQL server is also included for the discussion. This site has many other good features apart from technical discussions.

To know more visit http://www.mywindowsclub.com and to start discussion on SQL Server related topics visit http://www.mywindowsclub.com/forum/Category44.aspx.

To register to this site click here.

Saturday, June 19, 2010

'Sev. 14 Errors' - Login failed for user 'NT AUTHORITY\SYSTEM'- Troubleshooting

Sometimes your SQL Error log might fill up with the error “Sev. 14 Errors – Login failed for user ‘NT AUTHORITY\SYSTEM’. [CLIENT : Local System ]”
This happens when user ‘NT AUTHORITY\SYSTEM’ local group does not have access to SQL Server and some service is trying to access SQL Server using this account.

To Trace out which services is causing this issue, first you will have to run the profiler. We do not require all the events, so we can apply the filter for profiler to capture only “Audit Login Failed” event class.

The results of profiler are below

With this data we can conclude that it is coming from SQLsafe application.


But from which process this is coming?

For this now we have to check the ClientProcessID column in the profiler results i.e. 5316 from the profiler results.

Now, when we check in the task manager of the server, PID 5316 is allocated for “SQLSafeBackupService.exe”

If PID is not visible in the processes Tab of TaskManager then go to “view” option and click on “Select Columns”. And choose PID (Process Identifier)



Now if we go to “services.msc” and check for the logon account of this service we see that this is running under “Local System” account.

Once the Logon account is changed to some service account which has access to SQL Server, then the error stops.



This article is also available in pdf format for downloading.
Please Click here to get your copy.


Sunday, May 23, 2010

Row Not Found at the Subscriber - Replication Issue

When you find an issue in replication with the error “The row was not found at the Subscriber when applying the replicated command.”, first we have to get the Transaction sequence number and Command ID from the error.
This can be found at Distributer to Subscriber history in replication monitor.

Once we get the Transaction Sequence Number and Command ID we can easily drill down to the command which is causing the issue by using sp_browsereplcmds. Before to this, we have to also find out publisher_database_id.

For finding publisher_database_id, we need to make use of Transaction Sequence Number and Command ID.
Query to find publisher_database_id using Transaction Sequence Number and Command ID
select * from msrepl_commands
where xact_seqno = 0x000BF8FB0003411E000400000000 and command_id=6



Once we get the publisher_database_id from the above query, then we need to execute the below query to get the command which is causing the error.
Query to find the command which is causing error
exec sp_browsereplcmds @xact_seqno_start = '0x000BF8FB0003411E000400000000',
@xact_seqno_end = '0x000BF8FB0003411E000400000000', @Command_id=6, @publisher_database_id=60


Once we get the command, we can manually sync the missing data from publisher to subscriber to make the replication work fine as before.

Note: All these commands have to be run on distribution database.

This article is also available in pdf format for downloading.
Please Click here to get your copy.





Friday, April 30, 2010

T-SQL - Find which Object resides in which FileGroup

To Find which object resides in which FileGroup in a database, run the below queries.

/**************** For SQL 2000 ****************/

Select Distinct OBJECT_NAME(SI.id) AS ObjectName
        ,SO.type AS ObjectType
        ,FG.GroupName AS FileGroupName
from sysindexes SI , sysfilegroups FG ,sysobjects SO
where SI.groupid = FG.groupid and
      SI.id = SO.id
Order by ObjectName

/**************** For SQL 2005 and SQL 2008 ****************/

Select Distinct OBJECT_NAME(SI.object_id) AS ObjectName
        ,OBJECTPROPERTYEX(SI.object_id,'BaseType') AS ObjectType
        ,FG.Name AS FileGroupName
from sys.indexes SI , sys.filegroups FG
where SI.data_space_id = FG.data_space_id
Order by ObjectName

Statistics Updated Date

Statistics in SQL Server refers specifically to information that the server collects about the distribution of data in columns and indexes. More information about Statistics on How to Create, Drop and update Statistics are covered here.
In this post, we will see how to retrieve the information on when a Statistics was last updated.
To retrieve this information, run the below query on one of the database.
SELECT OBJECT_NAME(OBJECT_ID) AS TableName, name AS IndexName, Type_desc AS IndexTypeTableType=Case When OBJECTPROPERTY(OBJECT_ID,'IsUserTable')=0 Then 'SystemTable' When OBJECTPROPERTY(OBJECT_ID,'IsUserTable')=1 Then 'UserTable' ENDSTATS_DATE(OBJECT_ID, index_id) AS StatsUpdatedDate 
FROM sys.indexes 
Where OBJECTPROPERTY(OBJECT_ID,'IsUserTable')=
Order by TableName

This query will list the indexes present on all of the user tables in a particular database and when their Statistics was last updated.

Ads