Author Archives: Ram - Page 10

When would use + operator or Concat function – SQL Server 2012

SQL Server 2012 introduced a new function called as concat().

Previous versions of SQL Server, the null values in any of the concatenated fields was handled by either using ISNULL or COALESCE functions or by CASE END statements.

Concat handles NULLs in any of the participating fields and suppresses them without additional code handling.

So use CONCAT() wherever applicable.

[cc lang=”SQL”]

— sample case when middle name is null
select * from [dbo].[employee]
where emp_id = ‘PMA42628M’

— simple concatenation fails
select fname + minit + lname as FullName from [dbo].[employee]
where emp_id = ‘PMA42628M’

— handling NULLs before SQL Server 2012
——————————————————————————-
select fname + isnull(minit, ‘ ‘) + lname as FullName from [dbo].[employee]
where emp_id = ‘PMA42628M’

select fname + coalesce(minit, ‘ ‘) + lname as FullName from [dbo].[employee]
where emp_id = ‘PMA42628M’

select fname + case when minit is null then ‘ ‘ else minit end + lname as FullName from [dbo].[employee]
where emp_id = ‘PMA42628M’
——————————————————————————-

— handling NULLs after SQL Server 2012
——————————————————————————-
select concat(fname, ‘ ‘,minit, ‘ ‘, lname) as FullName from [dbo].[employee]
where emp_id = ‘PMA42628M’
——————————————————————————-

[/cc]

Disable all page breaks in SSRS

There could be scenarios where we would like to remove all page breaks for a report and just would like to see all records in one single page.

Here are the steps :

  • Check all individual tablixes have pagebreak to be disabled

No_Page_breaks_1

  • On the report properties set interactivesize for height  = 0 (an interactive height of 0 means the report has an infinite length)

No_Page_breaks_2

  • You will get a warning that it might be non-performant and be aware of consequences if the dataset is returning massive rows.

No_Page_breaks_3

Other alternative option is to open the report solution XML i.e RDL file in BIDS and look for <Page></Page>  sections in entire RDL file and then insert below code

<InteractiveHeight>0in</InteractiveHeight>
<InteractiveWidth>0in</InteractiveWidth>

Disclaimer: Non HTML rendering is NOT supported

Easy Steps to move/Copy VMDK file in VirtualBox

I had a ~70 GB VM in virtual box to be moved into a different drive for the lack of space on original drive. Couple of screenshots below will help anyone trying to do the same.

  • Run VirtualBox Manager

VM_1

  • Go to File, Virtual Media Manager

VM_2

  • Click on the VM and say “Release”

VM_3

VM_4

  • In the next step there is very important instruction to either DELETE or KEEP the VM (Please use KEEP as we are trying to just move the location of VM and not delete it)

VM_5

  • By now the VM is released and removed from the virtual Box Manager, so we move to the desired location. So copy the contents of the folder containing VMDK file to your desired location now.

VM_6.JPG

  • Now change the location of preferred folder in virtual box manager (from file | preferences)

VM_7

 

  • When you close and open the Virtual Box Manager, you might see that the old VM is inaccessible but do not panic as we will set it right now.

VM_8.JPG

 

  • Right click the VM and say, remove

VM_9.JPG

 

  • Now you will see that the old VM is not seen even in the virtual box manager

VM_10

 

  • Go to Machine | Add

VM_12.JPG

 

  • Pick the location of desired folder and choose .VBOX file

VM_13.JPG

 

  • Now the VM listing is shown with the modified location in the virtual box manager

VM_14.JPG

 

  • Right click on the VM and go to settings | storage and you will observe that there is no listing of VMDK file in the Controller section. (the icon will be in red color)

VM_15.JPG

  • Add Storage as shown

VM_16.JPG

VM_17.JPG

  • Now choose “Choose existing Disk”

VM_19.JPG

VM_20.JPG

VM_21.JPG

  • Finally click on “start” to launch the VM from the new location.

VM_25

VirtualBox – Unable to insert the virtual optical disk [Path] into the machine – Solved

I was trying to use one of the virtual box VMs provided by oracle for OBIEE. one of the major obstacle was to download the ~30GB files without any interruptions.

After the file was downloaded and extracted to one .ova using 7-zip, I observed that windows 8.1 wasn’t showing higher resolution for the linux guest OS. To get the fully functioning display driver we need to install the “Guest Additions”. Then we can use Full screen and Seamless modes.

So I had 2 interdependent issues which we try to resolve :

  • Cannot change the host screen resolution
  • Cannot install guest Additions

Below 2 statements were run to modify the config settings of the host from run command in guest:

“c:\Program Files\Oracle\VirtualBox\VBoxManage.exe” vboxmanage setextradata “SampleAppv506p” CustomVideoMode1 1920x1200x32

“c:\Program Files\Oracle\VirtualBox\VBoxManage.exe” vboxmanage modifyvm “SampleAppv506p” –vram 128MB

Install Guest Additions

VB_Guest_Edition_steps

Then I checked and increased the VRAM for guest and then tried to install the guess addition CD image. It gave this error :

VB_Guest_Edition_error

Then say “Force Unmount”

VB_Guest_Addition_Force_UnMOUNT.jpg

Now this requires sudo password to be provided. I wasnt sure of the password as it was pre-built oracle virtual box VM. But luckily enough since I had root access (i.e the default user account was already administrator type) I was able reset the password.

Sudo reset password

Finally gave the password to proceed with the installation.

VB_Guest_Addition_Password

If it still doesnt work, manually eject the disk in the CDROM, by clicking on the Eject button, after selecting the CDROM device. Then try to remount Guest Additions as suggested

Diagnostic Tests for SQL Server

Power settings in OS and IOS

  • Max performance and BIOS is also updated (because power saving cycles down the CPU and the performance may be reduced by as much as 20%)

SQL MaX Memory settings

  • set it to 90% of OS memory for upto 16GB; and then 1GB for every 4GB increase on RAM
  • if other MSBI suite of products are installed, appropriately assign more memory for OS

if the OS doesnt have enough memory and SQL takes up all then OS starts eating up the memory allocated to active processes and slows down entire system

Disk Cluster size

  • set it to be in the chunks of 64Kb

Auto-shrink/Auto-close

  • disable on all Dbs