Monday, February 2, 2015

About SQL Views


Views :
  • A View is nothing more than a saved SQL query. A view can be considered as virtual table
  • A view can have a maximum of 1,024 columns. 
  • If we Insert or Delete from view than this will also effect on our Actual Table
  • If a trigger is set on a table and we perform DML operations on that table by views than trigger will be called

Syntax for creating view
 
create view myview1
AS
select * from test1

Syntax for  Dropping View

drop view myview1

Syntax to use View

select * from myview1


Sunday, November 30, 2014

How To Hide DIV using JavaScript

In order to hide Div or any other control use the following code

To Hide

document.getElementById("Div1").style.display = 'none';

To Show
  
document.getElementById("Div1").style.display = 'block';

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

Saturday, October 4, 2014

Clustered Index VS Non Clustered Index in SQL

Clustered Index

  1.  cluster Index determines the physical order of data in a table
  2.  Primary key automatically Create a Cluster Index
  3.  A table can only have 1 cluster index, but 1 cluster index can have multiple column
  4.  Int and nvarchar both can have clustered index but nvarchar should not have max
  5. Cluster indexes are faster than non Clustered Index because both index and data are on same table
How to create a Cluster index

     Create Clustered index [cluster-name]
     on tablename(ColumnName)
 

Non Clustered Index

  1. In a Non-Clustered Index the index is stored seperately
  2. Just like a book the index is stored at the first page and data is on the other page
  3. A table can contain more than 1 non clustered index
  4. non Cluster indexes are slower than Clustered Index because index and data are on different table
  5. Becuase non clustered index are stored in a seperate table they require additional disk space
How to create a Non-Cluster index

     Create nonclustered index [cluster-name]
     on tablename(ColumnName)

How to check if a tabel has index or not

Execute sp_helpindex [table-name]


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

Tuesday, September 30, 2014

How To Disable Checkbox using JavaScript

To Disable HTML checkbox using javascript use the following script

document.getElementById("chkRed").disabled = true;

To Enable change true to false

document.getElementById("chkRed").disabled = false;

where chkRed is the id of your Checkbox

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

Monday, September 29, 2014

How to bind Asp DropDownList Value and text

In order to bind Asp DropDownList value and text field use the following method

lets day DroDownList id is "ddl"

 List<taqi> objlist = new List<taqi>();
                taqi objt = new taqi();
                objt.Id = "2";
                objt.Name = "Taqi";
                objlist.Add(objt);   // adding item in list

                objt = new taqi();
                objt.Id = "1";
                objt.Name = "Ali";
                objlist.Add(objt);   // adding item in list
                                             // so we have added two items in list now we will bind dropdownlist

                ddl.DataSource = objlist;  
                ddl.DataTextField = "Name";    //Name field is define in the class called taqi
                ddl.DataValueField = "Id";        // Id field is define in the class called taqi
                ddl.DataBind();                        // finally we bind the dropdownlist

For your convenience here is the class source code

  public class taqi
    {

        private string id;

        public string Id
        {
            get { return id; }
            set { id = value; }
        }

        private string name;

        public string Name
        {
            get { return name; }
            set { name = value; }
        }
    }

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