Pages

Social Icons

Sunday, 8 January 2012

Add a Hyperlink to a URL in SSRS


There is no direct option to create a hyperlink in SSRS, however you still can create links. This is how. To add a hyperlink




  • In report design view, right-click the text box, image, or chart to which you want to add a link and then click Properties.
  • In the Properties dialog box, click Action.
  • Select Go to URL. An additional section appears in the dialog box for this option.
  • In Select URL, type or select a URL or an expression that evaluates to a URL, or click the drop-down arrow and click the name of a field that contains a URL.
  • Click OK.
  • (Optional) The text is not automatically formatted as a link. For text, it is helpful to change the color and effect of the text to indicate that the text is a link. For example, change the color to blue and the effect to underline in the Font section in the Home tab of the Ribbon.
  • To test the link, click Run to preview the report, and then click the report item that you set this link on.


Thursday, 22 December 2011

Difference between != NULL and IS NOT NULL


When you deal with NULL in SQL Server you basically work with 3-value logic with all the implications.

IF(@myVar != null)  vs  IF(@myVar is not null)

It basically boils down to the question

what is the difference between: @myVar = null vs @myVar is null

@myVar = null will always evaluate to null as what you are asking is: is the value in @myVar equal to UNKNOWN

As you do not know what the UNKNOWN is this question cannot by answered yes, or no so it evaluates to UNKNOWN

e.g.
    "is 1 = UNKNOWN" - I do not know
    "is 'a' = UNKNOWN" - I do not know
    "is UNKNOWN = UNKNOWN" - I do not know

The last one may be a bit tricky but just imagine that you have 2 boxes with candy and you do not know neither how many candy are in box1 one nor in box2 so asking.
so the answer is I do not know

the second one @myVar is null is different as it is like asking is the value in @myVar UNKNOWN

so the difference is that you specifically ask "is it true that the value stored in the variable is UNKNOWN?", so
    "is 1 UNKNOWN" - NO
    "is 'a' UNKNOWN" - NO
    "is UNKNOWN UNKNOWN" - YES

THX,
RS

Tuesday, 13 December 2011

Notepad in C#


Hi,
I have developed a small notepad in C# windows application. In this sample notepad i have given New, Open, Save, Save As, Cut, Copy, Paste, Undo,  Select All, Find, Word-wrap, Font and Color functionality.


Here I am attaching a zip file of the source code. Download Here


Thx,
RS

Thursday, 1 December 2011

Call jquery funtion when it is exist.


Some times we need to call a function after chceking that it is exist there or not. This is very simple in jquery. Use that function name in if and if is exist then it will go in if block.


Example : 
function temp(){
  // Sample Code
}

if(temp){
  temp();
}


Like this temp function execute only when it is awailable.

Update XML Node value in SQL-Server 2008


Sometimes we need to change the value of a node in Sql-Server. Here is the example by which we can update the xml node value


Example : 



DECLARE @StrXml AS XML = '<BooksHome><Books>1</Books><Books>2</Books><Books>3</Books><Books>4</Books><Books>5</Books><Books>6</Books></BooksHome>'


DECLARE @i INT = 1
DECLARE @j INT = 141


SET @StrXml.modify('replace value of (//BooksHome/Books[sql:variable("@i")]/text())[1] with sql:variable("@j")')


we can see the updated result as :


SELECT @StrXml

Tuesday, 29 November 2011

Count of Nodes in XML through Sql-Server

Hi,


Here is the example by which we can count that how many times a particular node is coming.



DECLARE @strXml XML = (
'<Parent>
<Child>1</Child>
<Child>2</Child>
<Child>3</Child>
<Child>4</Child>
<Child>5</Child>
<Child>6</Child>
<Child>7</Child>
</Parent>'

DECLARE @cnt INT 
SET @cnt = 
(
SELECT
COUNT(*) AS NodeCount
FROM
(SELECT @strXml) AS XmlTable(XmlColumn)
CROSS APPLY 
XmlColumn.nodes('/Parent/Child') XmlTableFunction(XmlColumn2)
)

Monday, 28 November 2011

Chaning extension of a file

This is very usefull code for me. This code I was needed when my solution was migrated from VS2008 to VS2010. In VS2008 we are using the naming convention for our function and SP's like this : dbo.<function_name>.sql and dbo.<SP_name>.sql but in VS2010 we are using <function_name>.function.sql  and <SP_name>.proc.sql. I want to commit som 100+ files from VS2008 t0 VS2010 so I uses below code which changes the file names.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace ConsoleApplication1
{
    class Program
    {
       static void Main()
        {
            //Path where all the files are stored.
            string[] filePaths = Directory.GetFiles(@"E:\test\");
            for(int i = 0;i<filePaths.Length;i++)
            {
                string oldFileName=filePaths[i].ToString();
                //This will remove the prefix and suffix name of the file
                string fileName = oldFileName.Substring(0,oldFileName.LastIndexOf("."));
                //This will add the suffix name of the file
                string NewFileName=@"E:\test\"+(fileName.Substring(fileName.LastIndexOf(".")+1))+".function.sql";
                //It creates the copy of the file
                File.Copy(oldFileName, NewFileName);
                //It deletes the old file
                File.Delete(oldFileName);
            }
        
        }
    }
}