Get all the column names of a table in SQL


Get all the columns of a table in SQL


select * from sys.all_columns C 
join sys.tables T on C.object_id = T.object_id 
where t.name like '%TABLENAME%' 
order by c.name




This query is used to get all the columns and their details in the result window. Hope it will be useful for a huge table... :-)


CSS class for Modal Popup Block and its Background


CSS class for Modal Popup Block and its Background




'.modalPopupBackground
'{
'    background-color: gray;
'    width: 100%;
'    height: 100%;
'    opacity:70%; /* changed the opacity 0.7 to 0.5*/
'    filter: alpha(opacity=70); /*z-index: 50001;*/
'    position: fixed;
'    overflow: hidden;
'    margin: 0;
'    padding: 0;
'    top: 0;
'    left: 0;
'}






'.modalPopupBlock
'{
'    border-style: none;
'    border-color: inherit;
'    border-width: medium;
'    background: #fff;
'    padding: 10px;
'    float: left;
'    top: 25%;
'    left: 25%;
'    position: fixed;
'    width: 450px;
'    height:auto;
'    border:5px solid #93908b;
'    z-index: 50002; /*--CSS3 Box Shadows--*/ /*Changed the z-index 99999 to 50001 */
'    -webkit-box-shadow: 0px 0px 20px #333;
'    -moz-box-shadow: 0px 0px 20px #333;
'    box-shadow: 0px 0px 20px #333; /*--CSS3 Rounded Corners--*/
'    display:block;  
'}



convert single digit number into multiple digit number

convert single digit number into multiple digit number

(or) Convert 1 into 000001

[String].Format("{0:000000}", 1 )

Output : 000001


[String].Format("{0:000000}", 9999 )

Output : 009999

Sample function to load asp.net gridview using sql


Sample function to load a normal asp.net gridview using sql




        protected void LoadGridViewUsingSQL()
        {
            string connStr = "server= local);database=Northwind;uid=userid;pwd=password";
            SqlConnection sqlConn ;
            SqlCommand cmd = new SqlCommand();     
            DataSet ds = new DataSet();
            SqlDataAdapter da = new SqlDataAdapter(cmd);


            cmd.CommandText = "Ten Most Expensive Products";
            cmd.CommandType = CommandType.StoredProcedure;
            using (sqlConn = new SqlConnection(connStr))
            {
                cmd.Connection = sqlConn;
                
                da.Fill(ds);
            }


            GridView1.DataSource = ds;
            GridView1.DataBind();
        }

To find out which table has the column name in DB - MS SQL

To find which table has the column name like 'test' in Database MS SQL


select * from sys.all_columns C 
join sys.tables T on C.object_id = T.object_id 
where C.name like '%test%' 




Validating Multiple Email with Semilcolon seperated


  function validateEmail(field) {
            var regex = /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i;
            return (regex.test(field)) ? true : false;
        }

        function validateMultipleEmailsSemiColonSeparated(value) {
            var result = value.split(";");
            for (var i = 0; i < result.length; i++)
                if (!validateEmail(result[i]))
                    return false;
            return true;
        }


For Validating Multiple Email with Semilcolon seperated

Keep ur coding aside.. Relax for some time..