Saturday, December 2, 2017

NTFS Missing Free Space- Windows



Quick Solution.

The issue was Shadow Copy Storage in my case.

Run the following command on command prompt.

VSSADMIN LIST SHADOWSTORAGE

Go to step 3 below for more information.



NTFS Missing Free Space- Windows

There could be various reasons which could account for Free disk space usage calculation discrepancy.

First

check to see if your files are all actually visible with the current user account and Explorer settings.  Uncheck the “Hide protected operating system files” and select “Show hidden files and folders”.  When this is completed, look at the disk size again.


Does this accounts for the missing space No, try Step 2.


Second

Run CHKDSK and save the output.  The summary information at the end is what we want to see.


Based on above CHKDSK output we can account for metadata usage by adding up the following.


Still missing Space Yes, then Try step 3

Third)

Is Volume Shadow Copy enabled on ANY of the volumes?
Run the following command on command prompt.

VSSADMIN LIST SHADOWSTORAGE





For above output, you could see that C drive is blocking around 82 GB of disk space to store Shadow Copy on G drive.

This was the issues that I was facing.





Saturday, November 25, 2017

How to get Host name and SQL Instance Name in T-SQL

Run


SELECT SERVERPROPERTY('MachineName') AS [ServerName],
       SERVERPROPERTY('ServerName') AS [ServerInstanceName],
       SERVERPROPERTY('InstanceName') AS [Instance],
       SERVERPROPERTY('Edition') AS [Edition],
       SERVERPROPERTY('ProductVersion') AS [ProductVersion],
       Left(@@VERSION, Charindex('-', @@VERSION) - 2) AS VersionName
or

SELECT @@SERVERNAME





How do I identify the particular Linux flavor via command line?

Try the below command.... It worked for me...

cat /proc/version

Once you know that you are running Red Hat for example, you can get to the point with:

cat /etc/redhat-release

Or on Debian:

cat /etc/debian_version

or in general :

cat /etc/*-release

Also you could use the following command

cat /etc/issue

T-SQL Insert Into with CTE

CTE doesn't work with Insert into in nested queries.

With AS has be the first line of query.

and Insert Into can only work if the query finally ends with Insert into clause.

Work around is to split the query in 2 parts.

Where store one set of results in Global temp table.

like

select * into ##ramit from( select * from ----) as temp;