27 February, 2013

Removing a Server name from MS SQL Server Management Studio 2008 'Connect to Server' Drop-down list


Download utility from http://ssmsmru.codeplex.com/

OR

Rename Or Delete following file.

In Windows 7, it's in the following:

SQL 2005:
C:\Users\<USER>\AppData\Roaming\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat

SQL 2008:
C:\Users\<USER>\AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin


In Windows XP, it's in the following:

SQL 2005:
C:\Users\<USER>\AppData\Roaming\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat

SQL 2008:
C:\Users\<USER>\AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin

15 February, 2013

MySQL CONCAT address into string seperated by comma

CONCAT_WS() does not skip empty strings. However, it does skip any NULL values after the separator argument.

NULLIF(expr1,expr2) Returns NULL if expr1 = expr2 is true, otherwise returns expr1.
SO your query could be:

SELECT 
  CONCAT_WS(', ', 
       NULLIF(location_address1, ''),
       NULLIF(location_address2, ''),
       NULLIF(location_town, ''), 
       NULLIF(location_region, ''), 
       NULLIF(location_postcode, ''), 
       NULLIF(country_name, '')
  ) AS address
FROM
   countries c      
WHERE
   c.country_id = locations.country_id LIMIT 1

11 February, 2013

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information

Problem:
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

Solution:
To know in details what exactly happen add one more catch block like below.

catch (ReflectionTypeLoadException ex)
{
    StringBuilder sb = new StringBuilder();
    foreach (Exception exSub in ex.LoaderExceptions)
    {
        sb.AppendLine(exSub.Message);
        if (exSub is FileNotFoundException)
        {
            FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
            if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
            {
                sb.AppendLine("Fusion Log:");
                sb.AppendLine(exFileNotFound.FusionLog);
            }
        }
        sb.AppendLine();
    }
    string errorMessage = sb.ToString();
    //Display or log the error based on your application.
}