Write a sql query which will give result of the city name of the employee whose avg salary > 2000

select cityname, avg(salary) as avgsal from Employee   group by cityname  having  avg(salary) >2000

Asked in many Interview questions,Many Interviews

Find and Delete duplicate records in a table

Many times you can face problem of duplicate records in table.So How would you identify and delete duplicate records in a table? 
For that Firstly check if table has duplicate records or not using below query. 

Query :

SELECT [FirstName] FROM tblTest GROUP BY [FirstName] HAVING COUNT(*) > 1

Then Delete duplicate records.

DELETE FROM tblTest WHERE ID NOT IN (SELECT MAX(ID) FROM tblTest GROUP BY [FirstName])

A stored procedure can be called from a trigger, another stored procedure or even from a client applications. Are all the above statements correct ?

A stored procedure can be called from a trigger, another stored procedure or even from a client applications. 
Are all the above statements correct ?

 

Ans)

Yes, a Stored Procedure can be called from all the above statements.

 

A stored procedure must contains at least three parts: (1) stored procedure name (2) parameter list (3) its body

A stored procedure must contains at least three parts: 
(1) stored procedure name 
(2) parameter list 
(3) its body

Ans)

3 Parts are necessay, see the exmaple.

 here's an example to depict the fact:- 

Create Procedure usp_delete_customer 
@cust_id int

AS 

BEGIN 
delete from tbl_customer 
where cust_id = @cust_id
END 

Here:- 
(1) usp_delete_customer is the name of the stored procedure. 
(2) @cust_id int is the parameter 
(3) Inside the BEGIN and END tag is the body of the procedure

What is the difference between Pre-Render and Render events in ASP page execution


What is the difference between Pre-Render and Render events in ASP page execution ?

Ans)

Generally,

Pre Render - This event is used for modifying server controls just before sending them to client.

Render - This event is used to put the HTML output to the response stream

So in page life cycle event we found only  Pre Render Event only.

Different between Response.TransmitFile and Response.WriteFile ?


Different between Response.TransmitFile and Response.WriteFile ?

Ans)
TransmitFile : sends the file to the client without loading it to the Application memory on the server. It is the ideal for if the file size being download is large.

WriteFile : loads the file being download to the server’s memory before sending it to the client. If the file size is large, you might the ASPNET worker process might get restarted.

What is UDDI ?


What is UDDI ?

Ans)
UDDI - Universal Description, Discovery, and Integration (UDDI)

This is an XML based registry for businesses worldwide to list themselves on the Internet and a mechanism to register and locate web service applications.

It also provides a searchable directory of businesses and their Web Services. Hence this acts as a Service Broker that enables service requester's to find a suitable service provider.

Is it good to store connection strings in a separate text file for your application ?


Is it good to store connection strings in a separate text file for your application ?

Ans)
No, it is absolutely not advisable to store connection strings in a separate text file. If you want to store it anyway, then try storing it in a config file. Text files are easily accessible through web browsers but config files are not.... 

Generally Reference types are inherited from which class?


Generally Reference types are inherited from which class?

Ans)

Reference types inherit directly from System.Object , while all other value types are inherited directly from a type called ValueType, which in turn inherits from "System.Object."

Which of the following are known to be the attributes of an Object ?


Which of the following are known to be the attributes of an Object ?

Ans)
Polymorphism,Inheritance and Encapsulation are said to be the attributes of an object