Posts

Showing posts from January, 2013

To display number of sales for each day from begin date or Sql query to Group by day in sql server

SELECT DATEADD(DAY, DATEDIFF(DAY, 0, SMD.CreatedDate), 0) AS CreatedOn
    ,COUNT(SMD.CreatedDate) as [Count]       
    FROM TableName SMD
    GROUP BY DATEADD(DAY, DATEDIFF(DAY, 0, SMD.CreatedDate), 0)

How can you retrieve a reference to the current application domain?MCTS 70-536 Sample Example

A.  AppDomain ad = AppDomain.Current;
B.  AppDomain ad = Thread.GetDomain();
C.  AppDomain ad = Thread.CurrentThread.CurrentDomain;
D.  AppDomain ad = AppDomain.GetCurrentDomain();

You need to ensure that when the ProcessingComplete event is raised, an instance of the ProcessComplete class is provided to event subscribers. Which base class should you use for the ProcessComplete class?

You need to ensure that dates and numbers are displayed correctly for each user based on location. Which code segment should you add to line GL08 of the Global.asax file?

• You need to log an entry in a custom event log when the EmailSenderService service is started and stopped. What should you do? (Each correct answer presents part of the solution. Choose three.)

To count total number of objects is created for any Class in c# or Asp.net

public class Class1
    {
        static int Count = 0;

        public Class1()
        {
            Count++;
        }

        ~Class1()
        {
            Count--;
        }

        public static int getCount()
        {
            return Count;
        }

    }

class Program
    {
        static void Main(string[] args)
        {

            Class1 obj;

            for (int i = 0; i < 10; i++)
            {
                obj = new Class1();
                Console.WriteLine("Current Count" + Class1.getCount());
            }

            Console.ReadLine();
        }
    }

To count controls Names in page in asp.net

foreach (Control c in Page.Controls)
        {
            if (c.Controls.Count > 0)
            {
                foreach (Control c2 in c.Controls)
                {
                    lbl.Text += c2.GetType().Name + "<br/>";                  
                }
            }
        }

second highest salary in sql without using top and with using top in sql server

--Second hightest Salary without using top SELECT*FROM emp e1 WHERE 2 =(SELECTCOUNT(DISTINCT (e2.sal))FROM emp e2 WHERE e2.sal >= e1.sal)
SELECTTOP 1 sal FROM (SELECTDISTINCTTOP 2 sal FROM emp ORDERBY sal DESC) a ORDERBY sal
second lowest salary in sql without using top and with using top
--Second lowest Salary SELECT*FROM emp e1 WHERE 2 =(SELECTCOUNT(DISTINCT (e2.sal))FROM emp e2 WHERE e2.sal <= e1.sal)
SELECTTOP 1 sal FROM (SELECTDISTINCTTOP 2 sal FROM emp ORDERBY sal ) a ORDERBY sal DESC Just change the number u can get n th salary for Employee

with cts as
(
select Name,rn=ROW_NUMBER() over (order by Salary desc) from SalaryTable 
)
select Name from cts where rn in (2,5)