Tag Archives: error

How to get the default error log path for SQL Server with T-SQL

Below is a script to get the default error log path for SQL Server and set it as a variable. 

USE MASTER;
GO

DECLARE @LogPath AS VARCHAR(MAX)
DECLARE @ErrorLogPath TABLE (
	LogDate DATETIME
	,ProcessInfo VARCHAR(255)
	,PathText VARCHAR(MAX)
	);

INSERT INTO @ErrorLogPath
EXEC xp_readerrorlog 0
	,1
	,N'Logging SQL Server messages in file';

SET @LogPath = (
		SELECT REPLACE(REPLACE(REPLACE(PathText, 'Logging SQL Server messages in file ', ''), '''', ''), 'ERRORLOG.', '')
		FROM @ErrorLogPath
		);

SELECT @LogPath AS DefaultLogPath;
GO

 

Featured Image: A picture of a robot painting error over and over again

How to fix a Google Play Error -24

 

I had previously attempted to install an app but the device shut down mid installation. When I tried to install the app again at a later point in time the installation failed resulting in the Error -24 being shown on the play store.

So chances are you, as I did, are seeing an Error -24 message because remnants of a previous app installation remain.

Prerequisites to solving the problem:

To resolve this error install a file browser that will navigate to the system folders of the device, i.e. Root Browser. (Note: you’ll need root access to get to the necessary folder. You can view the following tutorial for an idea of what’s involved in rooting your device.)

Solution For An Error -24 :

STEP 1: In Root Browser tap the Data folder, then tap the Data folder again (One data folder is inside the other)

STEP 2: Find the remnant of the previous installation e.g. com.your.packagename and delete it. At this point you can try install the app again. If the installation fails repeat steps 1 & 2 and then move onto step 3.

Warning this next step is necessary but may have unwanted consequences as it involves wiping the cache of Google Play Services. The following paragraph is an over view of what google play services is and what it does. After reading the description you will be proceeding at your own risk.

Google Play services is used to update Google apps and apps from Google Play.
This component provides core functionality like authentication to your Google services, synchronized contacts, access to all the latest user privacy settings, and higher quality, lower-powered location based services.
Google Play services also enhances your app experience. It speeds up offline searches, provides more immersive maps, and improves gaming experiences.
Apps may not work if you uninstall Google Play services.

STEP 3: Go to Android Settings > Apps > swipe to All and scroll down to Google Play Services, tap on the app and then tap on clear cache button.

You should now be able to download and install that pesky app.

How to remove NaN and Infinity from a SSRS table

Typically this occurs when a field uses an expression in a report table were the expression tries to divide a number by zero (Or the field can populate with #Error when there is a NULL involved). The best solution to resolve this problem is to create a custom function.

Right click on the background of your report (i.e. just below where it says Design) and go to Report Properties as shown:

picture showing user where to click in the reportThen you can left click on Code and add enter the custom code below in the window provided:

Public Function Divide(ByVal dividend As Double, ByVal divisor As Double) As Double
   If IsNothing(divisor) Or divisor = 0 Or IsNothing(dividend) Or dividend = 0 Then
      Return 0
   Else
      Return dividend / divisor
   End If
End Function

IsNothing() is used to avoid #Error and check whether the divisor or the dividend are 0 to avoid NaN and Infinity.

Now change the field expression from, for example:

SUM(Fields!A.Value)/SUM(Fields!B.Value)

To the expression below using the newly defined function Divide:

= Code.Divide(Sum(Fields!A.Value), Sum(Fields!B.Value))

Next you can update the fields textbox properties to make the number display as a percentage.

NOTE: Inserting a user defined function into a table will mean that that table will no longer be able to be copied and pasted as this throws an error. To copy and past the table you will need to look at the code of the report by right clicking on the report and choosing View Code. Search for “Code.Divide” and comment it out with an apostrophe ( ‘ ). You will now be able to copy the table.

Universal Error Logging for Stored Procedures in SQL Server

Probably the best way to log whether your stored procedure ran correctly or threw an error during its run is to create another stored procedure to capture the events of the run.

This example although basic captures the primary data you would want to keep a record of regarding a procedures run.

  • The name of the stored procedure
  • The start time of the stored procedure
  • The time the stored procedure finished/errored
  • A user comment/error message
  • An assigned Log ID

Below is a pre-baked example requiring just a change to the DatabaseName, and if you wish SP_Name, text fields, as instructed in the comments of the SQL below, to test run the script.

This will create a SP_Log table and the stored procedure InsertRunIntoSpLog which can be reused over and over again when making stored procedures for other jobs to log the success/failure of these jobs.

Step 3 is an example stored procedure, which can be renamed as something other than SP_Name, which simply displays the date time.  Once created whenever the following is executed, EXEC dbo.SP_Name, the current date time will be returned and a record of the procedures run will be added to a row in the SP_Log table.

Although as stated above this is a basic example it is a very powerful foundation which can be built upon for very comprehensive event and transaction logging.