Sunday, May 10, 2015

Add Leading Zero in Excel

If you want to add leading zero's in your excel column so that your value become like following

123 > 0123
9827 > 09827
0000 > 0000

1. Select the column on which you want to apply this setting, and click Ctrl + 1

This will open Format Cell's dialog box

2. For the Category Select Custom

Now lets assume you need to enter 01234

3. So in type column just type 000#, and click on OK

That's it now if you enter 01234 in that column excel will accept it, and will not remove leading zero
I hope it was informative for you and I would like to thank you for reading.

Sunday, May 3, 2015

IF NOT EXISTS For Sql Functions

You must have used IF NOT EXISTS for DML operation, but the same method doesn't work for sql function.

In this tutorial I'm gonna show you how to use IF NOT EXISTS to create a function if it is already not created.

Download .Sql file for this project from HERE
IF EXISTS (SELECT * FROM [dbo].[sysobjects]
           WHERE ID = object_id(N'[dbo].[myfunction]')
    DROP FUNCTION [dbo].[myfunction]

create function myfunction()
 returns int
       return 5+4;

The idea here is to check if the function exists, if it exists than we will first drop it, and after that we can create the function.

I hope it was informative for you and I would like to Thank you for reading.