Ways you could you limit the number of records returned by SQL query?
There are 2 ways you can do that,
1. set ROWCOUNT to the required number of rec
2. Use TOP in select query
What's the difference, well not much except ROWCOUNT will override TOP if latter value is less. And ROWCOUNT affect subsequent queries.
One of areas ROWCOUNT comes in picture is say you need a Stored Procedure in which you are passing number of records your query must return as a parameter (@paramcnt), here TOP will not be of much use as you cannot have query like 'SELECT TOP @paramcnt FROM ...' but you definitely can put 'set ROWCOUNT @paramcnt', thats my observation......share yours.
Friday, February 8, 2008
Friday, January 25, 2008
Another question....
class A
{
public A()
{
Console.WriteLine("Me A");
}
}
class B : A
{
public B()
{
Console.WriteLine("Me B");
}
}
If an object of class B is created which constructor will fire first?
{
public A()
{
Console.WriteLine("Me A");
}
}
class B : A
{
public B()
{
Console.WriteLine("Me B");
}
}
If an object of class B is created which constructor will fire first?
Thursday, January 17, 2008
Enums - some more basics
Consider enum below
enum test:int
{
a,
b,
c = 5,
d
}
What will the following code display
static void Main(string[] args)
{
Console.WriteLine((int)test.a);
Console.WriteLine((int)test.b);
Console.WriteLine((int)test.c);
Console.WriteLine((int)test.d);
Console.ReadKey();
}
enum test:int
{
a,
b,
c = 5,
d
}
What will the following code display
static void Main(string[] args)
{
Console.WriteLine((int)test.a);
Console.WriteLine((int)test.b);
Console.WriteLine((int)test.c);
Console.WriteLine((int)test.d);
Console.ReadKey();
}
Wednesday, January 16, 2008
Question on hiding instance variable
Consider the class below
class joel
{
public int num = 0;
public void displaynum()
{
int num = 1;
}
public void displaynextnum()
{
num = 2;
}
}
What will below codes print and why?
1. joel j = new joel();
j.displaynum();
Console.WriteLine("Display member " + j.num);
Console.ReadKey();
2. joel j = new joel();
j.displaynextnum();
Console.WriteLine("Display member " + j.num);
Console.ReadKey();
class joel
{
public int num = 0;
public void displaynum()
{
int num = 1;
}
public void displaynextnum()
{
num = 2;
}
}
What will below codes print and why?
1. joel j = new joel();
j.displaynum();
Console.WriteLine("Display member " + j.num);
Console.ReadKey();
2. joel j = new joel();
j.displaynextnum();
Console.WriteLine("Display member " + j.num);
Console.ReadKey();
Subscribe to:
Posts (Atom)