Wednesday 11 February 2015

How to use the IsNothing Inspection Function in SSRS

A common tool used in building SQL Server reports is expressions, to either control content or appearance. Functions are almost always used at some point within an expression. A particular function we are going to touch on in this article is called "IsNothing". This function will let you inspect the value of an object to find out if it is NULL or not. There are various scenarios where this function can be used, but I am just going to touch on two that I think you might find used the most.
I am going to be using SSDT-BI for Visual Studio 2012. To let you know, to access the Expression Editor on any property within a report you will generally see an icon similar to this:

In other areas of SSDT-BI it might simply be a link titled "Expression...". 

The Report Data
In order to try and keep things as simple as possible on the setup, I am just going to use SQL Server backup history as the data for this example. I will assume you are already familiar with setting up your data source and dataset within SSDT-BI. The query below is what I will be working with:
SELECT d.name AS DatabaseName
,MAX(b.backup_finish_date) AS last_full_backup
FROM sys.databases AS d 
LEFT OUTER JOIN msdb.dbo.backupset AS b ON b.database_name = d.NAME
WHERE d.name <> 'tempdb' AND b.type = 'D'
GROUP BY d.name
UNION
SELECT d.name AS DatabaseName
,NULL AS last_full_backup
FROM master.dbo.sysdatabases AS d
LEFT JOIN msdb.dbo.backupset AS b ON b.database_name = d.name
WHERE b.database_name IS NULL AND d.name <> 'tempdb' 
ORDER BY d.name

Scenario 1: Color Formatting

If you were to just put this dataset in a table on the report it would look something similar to the below image:
This looks rather dull to see an empty cell in the table and requires that I still skim down the table to find those databases missing a backup. Adding a bit of color to those cells that are NULL can make this report much easier to read through.The cell for the value of "last_full_backup" can be modified to use an expression for the fill color to achieve this goal. You would access this via the text box properties, under the fill tab.


In this instance we basically want to know if a date is returned or a NULL value is returned. This is where the IsNothing is utilized within the expression. You can use an expression similar to the following:

=IIF(IsNothing(Fields!last_full_backup.Value),"IndianRed","Transparent")

Once I have done that and preview the report, it changes the report to something that is a bit more appealing:


Now alternative to simply just coloring in the cell would be to color the complete row, but I will leave that to you to try on your own.

Scenario 2: Value Manipulation
Now, let us say instead of formating the cell with a fill color I just want to change the NULL to be an actual value. So instead of a NULL value I am going to populate the cell with the text "***NONE***". To get this result you are going to use an expression for the value of text box itself.
In the same example above go back into the text box properties, and then within the general tab you will click on the expression button for the value "last_full_backup":
You will use an expression similar to the color expression to achieve the goal of populating a value instead of leaving it NULL:
=IIF(IsNothing(Fields!last_full_backup.Value),"**NONE**",Fields!last_full_backup.Value)
Apply this to the report and then the preview will return something similar to this (highlighted the cells with the value):


Tuesday 10 February 2015

To changed register manage account password in SharePoint, if it has change in the active directory

Cause: I have changed my farm credentials (password) in morning and just try to create web application.

The password supplied with the username Domain\username was not correct. Verify that it was entered correctly and try again.
I tried to create new web application using my farm credentials but no luck and it has given below error



There are two ways to change farm user Password

  • Using stsadm –
        This updates password forcefully without any validation
  • For SharePoint 2010
    • Go to command prompt and navigate to bin location of 14 hives
    • C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN
    • stsadm -o updatefarmcredentials -userlogin <domainusername> -password <newpassword>
    • It will give you message as “Operation completed successfully.”  
    •  Now reset IIS.
  • For SharePoint 2013
    • Go to SharePoint 2013 Management Shall
    • stsadm -o updatefarmcredentials -userlogin <domainusername> -password <newpassword>
    • It will give you message as “Operation completed successfully.”   
    • Now reset IIS.
It’s worked for me.

  • Using SharePoint Central Admin
    • Browse to your SharePoint Central Administration.
    • Navigate to Security from Quick launch.
    • Click on Configure Managed accounts under General settings as shown below.

    • Click on Register Managed Account to add the Service account which you would Change to.



    • Fill in the service account information in the Register managed Account.


    • If Password is not set base on password policy then gives error.
    • Now it’s time to change the Service account for the Web Application.
    • Navigate back to Security from Quick launch shown below and click on Configure Service accounts


    • In the Service Account page, select the Web Application for which you would need to change
    • Select the appropriate service account and hit OK.

    • Now Reset IIS.

Monday 9 February 2015

Missing Blank Site template SharePoint 2013

When setting up site collections, I mostly use the Blank Site Template. But in SharePoint 2013, there's a big "surprise": no Blank Site Template. Neither for Site Collections nor for sub sites:

There are two ways to enable blank site.


1)Create blank sites by using PowerShall

  • Run the command Get-SPWebTemplate to get the full list of the available templates. You can see, the Blank Site template is still there, and it's ID is STS#1:
  • From this point, creating a new site collection is as easy as this:
    • $template = Get-SPWebTemplate "STS#1"
      New-SPSite -Url "<URL for the new site collection>" -OwnerAlias "<domain\user>" -Template $template

2)you can enable this site template for the UI too. Just go to the folder C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\1033\XML, and open theWEBTEMP.XML file. There, you'll find a line like this:



  • <Configuration ID="1" Title="Blank Site" Hidden="TRUE"ImageUrl="/_layouts/15/images/stbs.png?rev=23" Description="A blank site for you to customize based on your requirements." DisplayCategory="Collaboration" AllowGlobalFeatureAssociations="False" > </Configuration>
just change the highlighted tag from Hidden="TRUE" to Hidden="FALSE", save the file, and that's it. next time you want to create a new site, you'll get the Blank Site Template.