How I find a particular column name within all tables of SQL server datbase.

For example, I have a database named Organisation. I have more than one table where tax_id column is present.

Most of the time, we have to find such a column from the whole database. The solution is provided below:
select table_name,column_name from information_schema.columns where column_name like ‘%tax%’

Here I am searching for column_name which contains tax within its name. It will return all the tables and respective columns containing tax.


Table_Name Column_name
t_Customer tax_id
t_Employee tax_number
t_Balance_sheet tax_percentage


Easy way to add Serial Numbers Column in Gridview

May occasions we need to give Serial numbers to our grid like 1,2,3,4,5, this I have tried my hand for a while and what I found…..


            Serial No.</HeaderTemplate>
            <asp:Label ID="lblSRNO" runat="server" 
                Text='<%#Container.DataItemIndex+1 %>'></asp:Label>

This code works as same when we apply paging.

We cannot use this on BoundFields because they support only those objects who have Databinding event

Get Full Month

ALTER FUNCTION [dbo].[getFullmonth]
@date1 date
date date not null
-- Set first day in month
DECLARE @month int;

SET @month = datepart(MM, @date1);
SET @date1 = convert(datetime, convert(varchar,datepart(yy,@date1)) + ‘.’ + convert(varchar,@month) + ‘.01 00:00:00’);
WHILE datepart(MM,@date1) = @month
INSERT INTO @dates VALUES (@date1);
SET @date1 = dateadd(dd, 1, @date1);