Wednesday, 23 July 2014

Query Cache SELECT Options

SELECT SQL_CACHE id, name FROM customer;
SELECT SQL_NO_CACHE id, name FROM customer;
 
More... 

Enable the query cache in MySQL to Improve Performance

To see the cache size: 
mysql> SHOW VARIABLES LIKE 'query_cache_size';  

 
To manage the cache size:
mysql> SET GLOBAL query_cache_size = 16777216;

 
More... 


 

Tuesday, 8 July 2014

MS SQL SERVER - String Comparison

Sometimes, comparing 2 strings can be a bit tricky in MS SQL Server. For example, if there is a field of name as varchar(n), containing the value of "Microsoft", it is actually treated as "Microsoft        " (fill the rest of field with spaces). Therefore using = always return wrong answer. Using LIKE however, return those strings which contains word Microsoft which is not the desired answer. The solution is to use PATTERN MATCHING as follow:

SELECT "Microsoft        " = "Microsoft[ ]%"

[ ]% represents the spaces


Thursday, 1 May 2014

APPML: Application Markup Language

What is <AppML>?

<AppML> is an application development framework, consisting of: 
  • An XML language for defining application models
  • A JavaScript running the the browser
  • A PHP or ASP script running on the server
more on W3C School...
more on faculty.kfupm.edu.sa...


Friday, 18 April 2014

Generate Random Numbers in C#

private static int seed = Environment.TickCount;

// Generate random number tick
private static ThreadLocal<Random> randomWrapper =
            new ThreadLocal<Random>(() => new Random(Interlocked.Increment(ref seed)));
           
randomWrapper.Value.Next(additionMinValue, additionMaxValue);


Tuesday, 15 April 2014

Reading repetitive XML to memory using C#

Sample XML Document:
<Elements>
    <Element>
        <Name>N1</Name>
        <Type>T1</Type>
        <Color>C1</Color>
    </Element>
    <Element>
        <Name>N2</Name>
        <Type>T2</Type>
        <Color>C2</Color>
    </Element>
    <Element>
        <Name>N3</Name>
        <Type>T3</Type>
        <Color>C3</Color>
    </Element>
</Elements>


Sample C# Code:
XmlDocument myDoc = new XmlDocument()
myDoc.Load(XML_File_Path_Name);

foreach(XmlElement elem in myDoc.SelectNodes("Elements/Element"))
{
    XmlNode nodeName = elem.SelectSingleNode("Name/text()");
    XmlNode nodeType = elem.SelectSingleNode("Type/text()");
    XmlNode nodeColor = elem.SelectSingleNode("Color/text()");

    string name = nodeName!=null ? nodeName.Value : String.Empty;
    string type = nodeType!=null ? nodeType.Value : String.Empty;
    string color = nodeColor!=null ? nodeColor.Value : String.Empty;



Analysis Service in Power BI Report Server

 We couldn’t connect to the Analysis Services server. Make sure you’ve entered the connection string correctly... link