Google Drive Trick – Google Spreadsheet Formatting Dates to String

I have been using google drive and google spreadsheet for a while. I work with experts around the world and we all use different date format. The biggest confusion which often happens when we are sharing data is a timestamp. For some people it is natural to have dates time like dd/mm/yyyy and for some it is natural to have mm/dd/yyyy. Sometimes we are just confused looking at the date as there is no instruction about the format. Finally, we all decided that we will spell out the dates. For example, if we have date like 11/9/2014 to avoid confusion if it is November 9, 2014 or September 11, 2014 we decided to just write it in the string.

Now here is the problem with Google Spreadsheet – when I type any datetime, like as following, it will immediately convert them to mm/dd/yyyy format and defeat our purpose of spelling that out.

Finally, we figured out the solution how we can preserve the datetime as a string in Google Spreadsheet. Just start your datetime with a single quotes. For example now we enter datetime as follows:

‘September 9, 2014 instead of September 9, 2014. The best part is that, the single quotes are not visible on the screen.

Well, if there was any other way to do this and I was not aware of it, please let me know.

Reference: Pinal Dave (

Professional Development – Dr W. Edwards Deming’s 14 Principles on Total Quality Management

I was just reading Dr. W. Edwards Demings 14 principles of Total Quality Management. It is indeed very impressive and interesting. I have tried to collect a few of the important resources related to the same over here.

Dr. Demings’s 14 principles

  1. Create a constant purpose toward improvement
  2. Adopt the new philosophy
  3. Cease dependence on mass inspection
  4. Use a single supplier for any one item
  5. Improve every process
  6. Create training on the job
  7. Adopt and institute leadership aimed at helping people do a better job
  8. Drive out fear
  9. Break down barriers between departments
  10. Get rid of unclear slogans
  11. Eliminate arbitrary numerical targets
  12. Permit pride of workmanship
  13. Implement education and self-improvement
  14. Make transformation everyone’s job

Here are few other interesting resources related to Dr. W Edwards Demings

  • Wikipedia page (Link)
  • Original White Paper with 14 Key Principles (Link)
  • Original Website of Demings Institute (Link)
  • SlideShare PPT (Link)

Here is the Official YouTube channel of Demings Institute. They have excellent videos and I strongly encourage everyone to view them.  Additionally, here is the famous Deming’s Red Bead Experiment Video.

Before I end the post I would like to include the video of Daniel Pink who has authored books Drive, which is very motivational book and often time I felt it resonated with the same message as Dr. Demings. This video is from TED presentation of Dan where he discussed The Puzzle of Motivation.

Reference: Pinal Dave (

Personal Technology – From Floppy to CD, DVD to USB Drive – Quick Note on Evolution of Personal Storage Device

Recently I was cleaning my house – clearing out old books and computer junk that I’ve been storing for a long time, when I found a box of floppy disks.  I was filled with nostalgia.  There was a time when I used floppy disks for everything – games, images, and so many backups!  I am the type of guy who is always thinking of backups, and floppies had a tendency to fail, so I always made backups of my backups.  Now here I was, holding all these useless floppy disks, and thinking of how the world has changed.

I hardly even see anyone with a floppy disk recently, let alone a computer with a floppy drive.  These floppy disks would only hold 1.44 MB, and I started remembering how I had to use a computer program called ZipDivider.  If you had a program or file that was larger that 1.44 MB, say 6 MB for example, you would need to use this program to divide it up into 1.44 MB chunks to fit on multiple floppy disks.  Then the other user would have to download all these files into a folder on their own computer, and starts zipping the files back together with another program.  This was an interesting experience, and a quick way to learn that you cannot damage even one floppy disk, or you would not be able to put together the file!

I was thinking about all these nostalgic programs when my daughter walked into the room.  She is four years old, and she had no idea what I was holding in my hand.  She asked me, “Why do you have a save button in your hand?”  She saw this floppy drive, and all she saw was an icon for the save function, the same way a bluebird represents Twitter, or a blue “F” represents Facebook.  I tried to explain to my daughter what a floppy disk is, that we used to use it as storage, and she just laughed and said “no, no, no, you store data on a USB drive!”  At this moment, I was speechless – because she is right!

At this point, my wife came in the room to tell me that she needed an mp3 burned onto a CD for a dance program at my daughter’s school – every student is performing a dance, and the school has old computers that need the music on a CD to play for the program.  I looked around and realized – my laptop does not have a CD drive, my servers don’t have CD drives, my desktop computer has a CD drive, but it doesn’t work!  I never installed the drivers to make it work.  So I spent some time downloading the drivers and CD writing software, only to realize that the program is not compatible with Windows 8.1.  I had to walk through our apartment building knocking on doors, and almost everyone said they didn’t have a CD driver, and didn’t even know how to use one!  Finally, our apartment manager answered his door – he is an older man, with an older computer.  After begging, pleading, and many thanks, he agreed to burn the mp3 to a CD for my daughter.

The world is changing so fast, it is like the ground is moving underneath us while we are still walking.  A floppy disk is just a save button, and no one knows about CD or DVD drivers!  We all use USB thumb drives and “cloud” storage like Dropbox.  So here is my question, and it is one I do not have the answer to: what is next now?  How will we communicate six weeks, six months, or six years from now?  How will we exchange files?  Will we even need to exchange files?  What is the next big thing?

Reference: Pinal Dave (


SQLAuthority News – MS Access Database is the Way to Go – April 1st Humor

First of all, today is April 1- April Fool’s Day, so I have written this post for some light entertainment. My friend has just sent me an email about why a person should go for Access Database. For a short background, I used to be an MS Access user once (I will not call myself MS Access DBA), and I must say I had a good time with Database at that time. As time passed by, I moved from MS Access to SQL Server. Well, as for my friend’s email, his reasons considering MS Access usage really made me laugh. MS Access may have a few points where it totally makes sense to use it. However, in the email that I received, there was not a single reason which was valid.  In fact, I thought it is an April 1st joke- just delivered a little earlier. Let us see some of the reasons from that email. Thanks to Mahesh Bhesania for sending this email to me.

  • MS Access comes with lots of free stuff, e.g. MS Excel
  • MS Access is the most preferred desktop database system
  • MS Access can import data from MS Excel and SQL Server
  • MS Access provides a real time database
  • MS Access has a free IDE-to-VB Script
  • MS Access fits well in your hard drive

I actually think that the above points are either incorrect beliefs of some users, or someone just wrote them to give some laughter with such inaccurate data. And, for the same reason I decided to browse the Internet and do some research on MS Access database to verify my thoughts.

While searching on this subject, I found the following two interesting statements from the site: Microsoft Access Database, Why Choose It?

  • Other software manufacturers are more likely to provide interfaces to MS Access than any other desktop database system
  • Microsoft Access consulting rates are typically lower for Access consultants compared to Oracle or SQL Server consultants

The second one is may be the worst reason for you to switch to MS Access if you are already an SQL Server consultant.

With this cartoon, have you ever felt like you were one of these chickens at some point in time? I guess that the moment might have just happened before the minute we say “I guess we were on the same page?” Does this mean we are IN the same table, or ON the same table?! (I accept bad joke!)

It is All Fools’ Day after all, so just laugh! If you have something funny but non-offensive to share, just  leave your comment here.

Reference: Pinal Dave (, Cartoon source unknown.

SQL SERVER – Enumerations in Relational Database – Best Practice

Marko Parkkola

Marko Parkkola

This article has been submitted by Marko Parkkola, Data systems designer at Saarionen Oy, Finland. Marko is excellent developer and always thinking at next level. You can read his earlier comment which created very interesting discussion here: SQL SERVER- IF EXISTS(Select null from table) vs IF EXISTS(Select 1 from table). I must express my special thanks to Marko for sending this best practice for Enumerations in Relational Database. He has really wrote excellent piece here and welcome comments here.

Enumerations in Relational Database

This is a subject which is very basic thing in relational databases but often not very well understood and sometimes badly implemented. There are of course many ways to do this but I concentrate only two cases, one which is “the right way” and one which is definitely wrong way.

The concept

Let’s say we have table Person in our database. Person has properties/fields like Firstname, Lastname, Birthday and so on. Then there’s a field that tells person’s marital status and let’s name it the same way; MaritalStatus.

Now MaritalStatus is an enumeration. In C# I would definitely make it an enumeration with values likes Single, InRelationship, Married, Divorced. Now here comes the problem, SQL doesn’t have enumerations.

The wrong way

This is, in my opinion, absolutely the wrong way to do this. It has one upside though; you’ll see the enumeration’s description instantly when you do simple SELECT query and you don’t have to deal with mysterious values. There’s plenty of downsides too and one would be database fragmentation.

Consider this (I’ve left all indexes and constraints out of the query on purpose).

CREATE TABLE [dbo].[Person]
[Firstname] NVARCHAR(100),
[Lastname] NVARCHAR(100),
[Birthday] datetime,
[MaritalStatus] NVARCHAR(10)

You have nvarchar(20) field in the table that tells the marital status. Obvious problem with this is that what if you create a new value which doesn’t fit into 20 characters? You’ll have to come and alter the table. There are other problems also but I’ll leave those for the reader to think about.

The correct way

Here’s how I’ve done this in many projects. This model still has one problem but it can be alleviated in the application layer or with CHECK constraints if you like.

First I will create a namespace table which tells the name of the enumeration. I will add one row to it too. I’ll write all the indexes and constraints here too.

CREATE TABLE [CodeNamespace]
[Id] INT IDENTITY(1, 1),

INSERT INTO [CodeNamespace] SELECT 'MaritalStatus'

Then I create a table that holds the actual values and which reference to namespace table in order to group the values under different namespaces. I’ll add couple of rows here too.

[CodeNamespaceId] INT NOT NULL,
[Description] NVARCHAR(100) NOT NULL,
[OrderBy] INT,
CONSTRAINT [PK_CodeValue] PRIMARY KEY CLUSTERED ([CodeNamespaceId], [Value]),
CONSTRAINT [FK_CodeValue_CodeNamespace] FOREIGN KEY ([CodeNamespaceId]) REFERENCES [CodeNamespace] ([Id])
-- 1 is the 'MaritalStatus' namespace
INSERT INTO [CodeValue] SELECT 1, 1, 'Single', 1
INSERT INTO [CodeValue] SELECT 1, 2, 'In relationship', 2
INSERT INTO [CodeValue] SELECT 1, 3, 'Married', 3
INSERT INTO [CodeValue] SELECT 1, 4, 'Divorced', 4

Now there’s four columns in CodeValue table. CodeNamespaceId tells under which namespace values belongs to. Value tells the enumeration value which is used in Person table (I’ll show how this is done below). Description tells what the value means. You can use this, for example, column in UI’s combo box. OrderBy tells if the values needs to be ordered in some way when displayed in the UI.

And here’s the Person table again now with correct columns. I’ll add one row here to show how enumerations are to be used.

CREATE TABLE [dbo].[Person]
[Firstname] NVARCHAR(100),
[Lastname] NVARCHAR(100),
[Birthday] datetime,
[MaritalStatus] INT
INSERT INTO [Person] SELECT 'Marko', 'Parkkola', '1977-03-04', 3

Now I said earlier that there is one problem with this. MaritalStatus column doesn’t have any database enforced relationship to the CodeValue table so you can enter any value you like into this field. I’ve solved this problem in the application layer by selecting all the values from the CodeValue table and put them into a combobox / dropdownlist (with Value field as value and Description as text) so the end user can’t enter any illegal values; and of course I’ll check the entered value in data access layer also.

I said in the “The wrong way” section that there is one benefit to it. In fact, you can have the same benefit here by using a simple view, which I schema bound so you can even index it if you like.

CREATE VIEW [dbo].[Person_v]
p.[Firstname], p.[Lastname], p.[BirthDay], c.[Description] MaritalStatus
FROM [dbo].[Person] p
JOIN [dbo].[CodeValue] c ON p.[MaritalStatus] = c.[Value]
JOIN [dbo].[CodeNamespace] n ON n.[Id] = c.[CodeNamespaceId] AND n.[Name] = 'MaritalStatus'
-- Select from View
FROM [dbo].[Person_v]

This is excellent write up byMarko Parkkola. Do you have this kind of design setup at your organization? Let us know your opinion.

Reference: Pinal Dave (

SQL SERVER – Policy Based Management – Create, Evaluate and Fix Policies


This article will cover the most spectacular feature of SQL 2008 – Policy-based management and how the configuration of SQL Server with policy-based management architecture can make a powerful difference. Policy based management is loaded with several advantages. It can help you implement various policies for reliable configuration of the system. It also provides additional administration assistance to DBAs and helps them effortlessly manage various tasks of SQL Server across the enterprise.

Basics of Policy Management

SQL server 2008 has introduced policy management framework, which is the latest technique for SQL server database engine. SQL policy administrator uses SQL Server Management Studio to create policies that can handle entities on the server side like the SQL Server objects and the instance of SQL Server databases. It consists of three components: policy administrators (who create policies), policy management, and explicit administration. Policy-based management in SQL Server assists the database administrators in defining and enforcing policies that tie to database objects and instances. These policies allow the administrator to configure and manage SQL server across the enterprise.

The following advantages can be achieved by appropriate administration of policy management system.

  • It interacts with various policies for successful system configuration.
  • It handles the changes in the systems that are the result of configuration against authoring policies.
  • It reduces the cost of ownership with simple elaboration of administration tasks.
  • It detects various compliance issues in SQL Server Management Studio.

Policy Management Terms

To have a better grip on the concept of Policy-based management there are some key terms you need to understand.

  • Target – A type of entity that is appropriately managed by Policy-based management. For example, a table, database and index, to name a few.
  • Facet -A property that can be managed in policy-based management. A clear example of facet is the name of Trigger or the Auto Shrink Property of database.
  • Conditions – Criteria that specifies the state of facet to true or false. For example, you can adjust the state of a facet that gives you clear specifications of all stored procedures in the Schema “Banking”.
  • Policy – A set of rules specified for the server objects or the properties of database.

Practical Example of Policy Management

Exploring of Facets

Facets are database objects and each of them is a container of one or more database object. First, you need to navigate the object explorer and expand the policy-based management node and the management node. You will see conditions, policies and facets nodes. SQL Server 2008 has many different facets available to use.

To view the list of facets, expand the facet node

Double click on each of these facets to the list of the facet properties.

Let us understand the two next elements of creating condition and creating policy with real life example of Statistics. We will try to create statistic property of the database. We have property of statistic IsAutoCreated. We can set that using database property window under option tab. This property takes two values True or False.

We will follow up on this property in different steps. We will first create condition and right after we will use the same condition in a policy. That policy will be evaluated by user. User will have to two options either let us evaluated by scheduled task or fix non complaining policy manually.

Create a Condition

Creation of condition in Policy-based management is the next thing after identifying the problem. In our case, we want to make sure that everywhere IsAutoCreate is set to True everywhere.

Each facet displays different kinds of properties. As we are interested in the IsAutoCreated property of the statistics we have to select facet as Statistic.

Create a Policy

Creating a policy is the next important task after creating a condition. The condition has to be created to select the proper property of the object. However, a policy is created to specify the location where the condition has to be applied.

Please follow the instructions given in the above image. Make sure to select all target databases. In given example I have two database installed on my server that brings up two different targets servers.

This brings up an interesting concept of targets. Targets are database objects. They can be whole database or single parts of the database. It may be possible that they are different kind of objects but have same kind of properties.

While creating a policy we have kept the evaluation mode as “on demand”, which means that we will be running this policy manually, instead of scheduled job. Scheduled job is good idea to run policy.

Evaluate a Policy

As in the previous step, we have selected to evaluate the policy manually; we will evaluate that using SSMS. Right click on policy brings up with lots of options. Select Evaluate from the menu, this will bring up the following image.

On the screen of Evaluate Policies there is a button which suggests evaluating the policies. Once clicked it will give the following kind of screen with a status.

You will see a green icon in the image. This icon indicates the policy evaluated the status to True. If you notice you will find that in our example all the policies are complied with.

Fix Non-complying Policy

Now, let us change the IsAutoCreate policy of one of test databases to true and run the evaluation all over again. If you observe you will notice that one of the statuses is marked as false with a little red image on the left.

Furthermore, once you select the checkbox and clicked on the Apply button you will find an additional checkbox on the side. This Apply button will raise a popup confirming that the property of the target has been changed to comply with the policy. Next, click Ok to confirm. This will change the properties of the Test database to comply with the new policy on all of our targets specified earlier.

In our example, we have manually evaluated the policy and fixed its noncompliance. With powershell you can perform the same using SQL Server Agent.


Policy-Based Management empowers you with greater control over the procedures of database as a Database Administrator. It provides you the ability to enforce paper policies at database level. Paper polices are used as guidelines for understanding database standards. However, it necessitates some skills, time and efforts to enforce these polices. You need to go with a fine toothed comb to enforce these policies. Policy-based management system helps you define these polices and ensure that they will be enforced appropriately.

Reference : Pinal Dave (, DNS

SQLAuthority News – Effect of Oracle acquiring MySQL – A Delayed Analysis

On 20 April 2009, Oracle Corporation announced its acquisition of Sun Microsystems in a deal worth about US$ 6 billion. This would have been just another one of corporate mega-deals that sound interesting in the news but really have no effect on your life. Except for the fact that with the purchase, Oracle acquired the world’s most widely used open-source database engine- MySQL. About 12 million small databases, mainly in websites and small businesses, run on the open-source MySQL platform, since it is stable, easily adaptable and most important of all for cash-strapped small companies, free. Note that ‘free’ here means that there is no software license to purchase (unlike commercial database engines like Oracle DB and Microsoft SQL Server), but most customers still have to pay third-party vendors for additional services like user interface design, technical support, bug fixes and so on. This is what makes the open-source model paradoxically both free and profitable.

First of all, why did Oracle buy Sun Microsystems? The main reason for the purchase was to get Sun’s major products- Sun hardware, Solaris and Java. The SunServer+Solaris+Oracle combination (especially the Oracle database), is globally used in mission-critical systems, from banks to hospitals to nuclear power stations, because of its stability and robustness. It is perhaps the most trusted combination of hardware, operating system and database there is. Java is also a key platform and supporting component for several Oracle products, for example Oracle’s Fusion Middleware is wholly built to run on Java.

So the MySQL acquisition was not really the focal point of the purchase, but it was nevertheless an important aside. Sun itself acquired MySQL in 2008 for about US$ 1 billion, Oracle now owns both of them. While Sun was known for its commitment to open source software, Oracle is a corporate giant without a track record for supporting open-source initiatives. So there arose understandable concern within the IT community about what will happen to MySQL. Will Oracle try to kill MySQL so that it does not compete with Oracle’s own offering? Will Oracle help to develop MySQL further as a platform? Will they leave it alone and not be bothered? Will they sell it off to another company? The real answer right now is that nobody knows, except perhaps Oracle senior management.

Major Outcomes

Let us now examine the different outcomes being put forth by pundits. The first one, from insiders like IHL Consulting Group President Greg Buzek, is the glum opinion that Oracle will kill off MySQL because it partially competes with Oracle’s own database engine. Matters are complicated more by the fact that even though Oracle is mainly bought by large organizations (whose chief concern is system stability, vendor robustness and support, and not the software license fee), while MySQL is primarily used by small companies and small websites, its development has recently scaled up and MySQL can now offer enterprise-class computing, which then becomes a major headache for Oracle.

Another reason given for Oracle deciding to bury MySQL is that the company is not really a supporter of the open-source model, instead preferring the tried and tested pay-per-license route. In fact Oracle is viewed with some suspicion in the open-source community- a sort of mega-corporation bent on world (software) domination. This is the chief cause for concern for the MySQL community. However, Oracle does have some redeeming acts in its interaction with open-source products. For example, the company has fully supported development of its software products to run on Linux.

The second possible outcome is that Oracle will continue to encourage and support MySQL development. One argument for this is that MySQL, as part of the Sun purchase together with Java and Solaris, offers Oracle CEO Larry Ellison a weapon to fight his main rival Microsoft. Also, don’t discount the fact that Oracle is keenly aware that MySQL is open-source, meaning its source code and original developers are still around. So even if Oracle were to try and kill MySQL, either by stopping development or by licensing and charging for it, the development community can simply start working on an open-source, similar clone application. This is how Linux itself was originally conceived- as a free spin-off of commercial Unix operating systems.

A third possibility is that Oracle executives may decide that MySQL is simply too much bother, and decide to sell off the company to someone else. Sun Microsystems acquired MySQL for about a billion dollars, and Oracle may decide that since MySQL was not the main reason they bought Sun anyway, they might as well dispose of it for roughly the same amount.

A fourth possible outcome is that Oracle may elect to offer support contracts and consulting on MySQL to companies that need a lighter-weight solution than Oracle’s full, and at times bloated, database products. In this way, they offer the comfort of their large-vendor status to the potential clients who may be worried about using open-source software- a shrewd market-capturing move.

But that same decision may have its own potential pitfall. Oracle’s main reason for buying Sun was to integrate and sell whole computing platforms. But IT managers might choose to avoid this one-vendor offering, from server to database application to support services, because it can also result in a single point of failure or arbitrary price changes in the platform’s licensing.


In conclusion, the truth is that simply don’t know what Oracle will do with MySQL. There are several interesting alternatives, some more viable than others. But it is safe to assume that in the short-term, Larry Ellison will not take any drastic steps that may alienate his huge client base. Only time will tell.

My Opinion

In many of the application, I do not need full featured SQL Server Enterprise Version. I just need something simple and free. This is when I use SQL Server Express Edition. You can read the complete reference over here SQL SERVER – SQL Server Express – A Complete Reference Guide.

Please contribute here with your comments and opinion.

Reference : Pinal Dave (