Friday 27 December 2013

SQL SERVER Query

select max(a) from
(
Select
(
  SELECT Max(v)
     FROM (VALUES (Theatre), (ClassRoom), (UShape),(Cabaret),(
DinnerDance),(Reception))
   AS value(v))as a
FROM PropertyMeetingRoom
)t

Monday 10 June 2013

How to check string is number or not in C#

 Some time we have required to check the value of string is Number or not if it no then offcourse       our   task on these like sum, avg, max etc etc but somehow it contain string value is not Numeric then its panic . Then what is the solution
Simply check the no if it is numeric then perform the action other wise no action performed.

Below is the simple example .
there are a method in C# which check the datavalue. Method name is TryParse
it returns always boolean value. 

Solution :

string strValue = "ABC";
double Num;
bool isNum = double.TryParse(Str, out Num); // out parameter are used
if (isNum)
Response.Write(Num.ToString());  // you use here your label id or other thing
else
Response.Write("Invalid number");
  // you use here your label id or other thing 

Friday 31 May 2013

How to get all table name dependent on any column in SQl Server

Query for this is

SELECT o.Name as Table_Name , c.Name as Field_Name, t.Name as Data_Type
, t.length as Length_Size
FROM syscolumns c
     INNER JOIN sysobjects o ON o.id = c.id
     LEFT JOIN  systypes t on t.xtype = c.xtype 
WHERE o.type = 'U'  and c.name like '%country%'
ORDER BY o.Name, c.Name

here red color name is your required column name .

Thursday 7 March 2013

Select Query in SQL Server


Hi all
I have a Question for   you .
I have one table with two columns a and b
like this
Create table  test(
a varchar(10),
b varchar(10)
)

After that i execute a query

select  a b  from test

Then my question is   what will be  the output of this simple query .
 

Friday 18 January 2013

Difference between === and == in javascript

if(1=="1")
{
alert("hello");
}else
{
alert("hi");
}

Some time question arises that what is the output.
what you think about this ?
of course your answer is hello .
But now can you guess what is the result of following code

if(1==="1")
{

alert("hello");
}else
{
alert("hi");
}
bit confusing .
answer is hi .
It is becuase the expreesion === to compare datatype as well as value .