30 July 2011

Operator OverLoading in console apps


class ClsComplex
    {
        int R, I;
        public ClsComplex(int R, int I)
        {
            this.R = R;
            this.I = I;
            Console.WriteLine("{0} + {1}i", R, I);
        }
        public static ClsComplex operator +(ClsComplex Num1, ClsComplex Num2)
        {
            ClsComplex Num3 = new ClsComplex(Num1.R + Num2.R, Num1.I + Num2.I);
            return Num3;
        }
    }
    class ClsOpOverLoad
    {
        static void Main(string[] args)
        {
            Console.Write("C1= ");
            ClsComplex C1 = new ClsComplex(4, 5);
            Console.Write("C2= ");
            ClsComplex C2 = new ClsComplex(8, 2);
            Console.Write("C3= ");
            ClsComplex C3 = C1 + C2;
            Console.Read();
        }
    }

28 July 2011

how to find out highest salaried employee details of a table in sqlserver



select * from tblEmp tbl1 where 0=(select count(distinct salary) from tblEmp tbl2 where tbl1.salary<tbl2.salary)

with s as (select *, row_number() over(order by sal desc) as rn from sam) select * from s where s.rn=1

max possible columns per a table in sqlserver is 1024

copy one column data into other column of a same table using query in sqlserver

update tblEmp set address1=address2

get the list of tables that r available in a particular database in sqlserver

select * from information_schema.tables

or

select * from sys.tables

get the list of columns that r available in a particular table in sqlserver

select column_name from information_schema.columns where table_name='tblEmp'

or

select name from sys.columns where object_id=object_id('tblEmp')

get the serial no. for records of table in sqlserver

select empname, row_number() over(order by empid)as 's.no' from tblEmp

27 July 2011

how to find out rank of employees based on their salaries

select empname,dense_rank()over(order by salary)as rank from tblEmp

how to find servername from sqlserver name using query

select host_name()


For app name:

select app_name()

how to find out highest salaried employee details of a table in sqlserver

select * from tblEmp tbl1 where 0=(select count(distinct salary) from tblEmp tbl2 where tbl1.salary<tbl2.salary)



max possible columns per a table in sqlserver is 1024 

copy one column data into other column of a same table using query in sqlserver

update tblEmp set address1=address2

get the list of tables that r available in a particular database in sqlserver

select * from information_schema.tables

or

select * from sys.tables

get the list of columns that r available in a particular table in sqlserver

select column_name from information_schema.columns where table_name='tblEmp'

or

select name from sys.columns where object_id=object_id('tblEmp')

get the serial no. for records of table in sqlserver

select empname, row_number() over(order by empid)as 's.no' from tblEmp

how to find out rank of employees based on their salaries

select empname,dense_rank()over(order by salary)as rank from tblEmp

how to find servername from sqlserver name using query

select host_name()


For app name:

select app_name()