SQL Server 2012/2014: Enabling and disabling trace flags

You can use the DBCC TRACEON command to turn on the specified trace flag. This is the syntax:

DBCC TRACEON (trace# [,…n][, -1]) [WITH NO_INFOMSGS]

If you want to turn off the specified trace flag(s), you can use the DBCC TRACEOFF command.
This is the syntax:

DBCC TRACEOFF (trace# [,…n] [,-1]) [WITH NO_INFOMSGS]

You can use the DBCC TRACESTATUS command to get the status information for the particular trace
flag(s) currently turned on. This is the syntax:

DBCC TRACESTATUS ([ [trace# [,…n] ] [,] [-1] ]) [WITH NO_INFOMSGS]

To get the status information for all trace flags currently turned on, you can use -1 for trace#.

This is the example:



Useful trace flags

1. Trace flag 1204.

This trace flag returns the type of locks participating in the deadlock and the current command
affected. This trace flag is documented in SQL Server 2012 Books Online. This is global trace flag.

2. Trace flag 1205 (undocumented).

This trace flag returns more detailed information about the command being executed at the time
of a deadlock. This trace flag was documented in SQL Server 7.0 Books Online, but is not
documented in SQL Server 2012.

3. Trace flag 1211.

This trace flag disables lock escalation based on memory pressure, or based on number of locks.
If turns on, then SQL Server 2012 will not escalate row or page locks to table locks.
Note. When the trace flag 1211 is turned on then excessive numbers of locks can be generated.

4. Trace flag 1224.

This trace flag disables lock escalation based on the number of locks. If both trace flag 1211
and 1224 are set, 1211 takes precedence over 1224.

5. Trace flag 1807 (undocumented).

You cannot create a database file on a mapped or UNC network location. This opportunity is
generally unsupported under SQL Server 2012. However, You can bypass this by turn on trace
flag 1807.

6. Trace flag 2508 (undocumented).

This trace flag disables parallel non-clustered index checking for DBCC CHECKTABLE.

7. Trace flag 2528.

This trace flag disables parallel checking of objects by DBCC CHECKDB, DBCC CHECKFILEGROUP,
and DBCC CHECKTABLE. Usually trace flags 2508 and 2528 should not be used because checking in
parallel provides better performance, but sometimes when another process requires CPU resources
during checking, you can disable parallel checking to free some CPU resources for another process.

8. Trace flag 3205.

This trace flag disables hardware compression for tape drivers. You can use this trace flag
if your tape drives do not support compression.

9. Trace flag 3608.

This trace flag skips automatic recovery (at startup) for all databases except the master
database. To turn on this trace flag, you must use -T startup option. For example, you should
start SQL Server 2012 with the following parameter: -T 3608
To make it, run Services from the Control Panel, double click on MS SQL Server service, click
Stop button, then specify parameter value (-T 3608) and click the Start button.

10. Trace flag 3609 (undocumented).

This trace flag skips the creation of the tempdb database at startup. To turn on this trace
flag, you must use -T startup option.

11. Trace flag 4616.

This trace flag makes server-level metadata visible to application roles. By default, an
application role cannot access metadata outside its own database. This is global only trace flag.


Taken from: http://www.sswug.org/alexanderchigrik/sql-server/useful-sql-server-2012-trace-flags/

Resizing the disk space on Ubuntu Server VMs running on VMware ESXi 5

Resizing the disk space on Ubuntu Server VMs running on VMware ESXi 5

We generally do both dedicated and VPS hosting for our websites, apps and some premium projects we run for others.When we choose to have VPS servers (aka virtual machines or VMs for short) instead of dedicated servers, we usually opt for VMware‘s free ESXi 5 and install Ubuntu Server as the OS for the VPSs we create on top of ESXi 5. It may not be as friendly as some VPS providers like Amazon, Rackspace etc. but you got more control and it’s on YOUR hardware (pretty important actually!)…

Now, when you build a VPS on VMware, you start with say 40GBs of hard disk space. You install the OS, setup the server, move the sites on this new server and you’re on. But what happens when there’s no more room on the server for your site or sites and you need to add more disk space?

The process is quite simple:

a) Connect to the VMware ESXi 5 server using the vShpere Client. Edit the VM’s properties to increase the hard disk size (VM has to be off) – I won’t get into details on that, if you have the experience on managing ESXi you know what to do… I’m assuming the process is the same for ESXi 4. Now restart the VM.

b) Login via SSH to the VM and follow this process.
– First list all partitions:
$ ls -al /dev/sda*

– Create new partition using fdisk:
$ fdisk /dev/sda
type p – to list all your partitions
type n – to create a new partition
type l – for “logical”
then give it a number (e.g. if you got 2 partitions listed as /dev/sda1 & /dev/sda2, for the new partition simply type “3” to create /dev/sda3)
type t – to change the partition type to “Linux LVM”
provide the partition number you previously created
type 8e – for the “Linux LVM” type
type p – to list the new partition table
type w – to write changes and exit

– Reboot server:
$ reboot

– Assuming you created partition /dev/sda3, let’s now create the physical volume in that partition:
$ pvcreate /dev/sda3

– Now let’s extend the server’s Volume Group to that physical volume.
$ vgdisplay
This will give you the info on your current Volume Group. Note down the entry next to “VG Name”. That’s your Volume Group name.
$ vgextend EnterVolumeGroupNameHere /dev/sda3

Keep in mind
If you get a message saying /dev/sda3 could not be added to your Volume Group, you need to remove the physical volume and recreate it. Metadata might have gotten corrupt and thus the volume cannot be added to your Volume Group. So just do:
$ pvremove /dev/sda3
And then again:
$ pvcreate /dev/sda3

– Since we’re (essentially) extending the main logical volume, let’s get the name of that:
$ lvdisplay
and note down the entry next to “LV Name”. This is your logical volume’s name (e.g. /dev/srv/root), which you’ll now extend to the newly added partition/physical volume.

– Extend the logical volume by X GBs:
$ lvextend -L +XG yourLogicalVolumeName
Make sure you replace X above with the actual number of GBs you’ve added in your VM’s settings. So if you increased your VM by 20GBs, the command becomes:
$ lvextend -L +20G yourLogicalVolumeName

– Finally, let’s resize the file system to the new allocated space:
$ resize2fs yourLogicalVolumeName
(this may take some time depending on number of GBs added to the file system.

– Check the new file system sizes:
$ df -hT
You should now see an increased disk space for your primary logical volume.

Installing VMware Tools in an Ubuntu virtual machine with only a command line interface

Ubuntu Server with only a command line interface

  1. Go to Virtual Machine > Install VMware Tools (or VM > Install VMware Tools).Note: If you are running the light version of Fusion, or a version of Workstation without VMware Tools, or VMware Player, you are prompted to download the Tools before they can be installed. Click Download Now to begin the download.
  2. In the Ubuntu guest, run these commands:
    1. Run this command to create a directory to mount the CD-ROM:sudo mkdir /mnt/cdrom

      When prompted for a password, enter your Ubuntu admin user password.

      Note: For security reasons, the typed password is not displayed. You do not need to enter your password again for the next five minutes.

    2. Run this command to mount the CD-ROM:sudo mount /dev/cdrom /mnt/cdrom or sudo mount /dev/sr0 /mnt/cdrom
    3. The file name of the VMware Tools bundle varies depending on your version of the VMware product. Run this command to find the exact name:ls /mnt/cdrom
    4. Run this command to extract the contents of the VMware Tools bundle:tar xzvf /mnt/cdrom/VMwareTools-x.x.x-xxxx.tar.gz -C /tmp/

      Note: x.x.x-xxxx is the version discovered in the previous step.

    5. Run this command to change directories into the VMware Tools distribution:cd /tmp/vmware-tools-distrib/
    6. Run this command to install VMware Tools:sudo ./vmware-install.pl -d

      Note: The -d switch assumes that you want to accept the defaults. If you do not use -d, press Return to accept each default or supply your own answers.

  3. Run this command to reboot the virtual machine after the installation completes:sudo reboot

Taken from: https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1022525


NAV 2013/2015/2016: Log in any database

Run this on a NAV 2013/2015/2016 database to clear all users and restore default permissions:


delete from [dbo].[User]

delete from [dbo].[Access Control]

delete from [dbo].[User Property]

delete from [dbo].[Page Data Personalization]

delete from [dbo].[User Default Style Sheet]

delete from [dbo].[User Metadata]

delete from [dbo].[User Personalization]

Force-removing the RDS licensing time-bomb

Force-removing the RDS licensing time-bomb registry entry:

HKLM\system\CurrentControlSet\Control\Terminal Server\RCM\GracePeriod

RegEdit alone couldn’t do it. It had to actually be run under highest privileges with the help of Sysinternals: psexec -s -i regedit.exe

After another reboot things seem to be working now.