Define SQL constraints

SQL constraints are the set of rules that impose some restriction while insertion, deletion or updation of data in the databases.In SQL we have both column level as well as…

Read more »

Q. Write a SQL query to fetch only odd rows from table.

Answer: Odd rows can be achieved by using Row_number in SQL server- SELECT E.EmpId, E.Project, E.Salary FROM ( SELECT *, Row_Number() OVER(ORDER BY EmpId) AS RowNumber FROM EmployeeSalary ) E…

Read more »

Q. Write a query to fetch employee names and salary records. Return employee details even if the salary record is not present for the employee.

Answer:  SELECT Emp.FullName, S.Salary FROM EmployeeDetails E LEFT JOIN EmployeeSalary S ON Emp.EmpId = S.EmpId;

Read more »

SQL query to remove duplicates from a table without using temporary table.

Ans. Using Group By and Having clause- DELETE FROM EmployeeSalary WHERE EmpId IN ( SELECT EmpId FROM EmployeeSalary GROUP BY Project, Salary HAVING COUNT(*) > 1));

Read more »

SQL query to fetch duplicate records from a table.

Ans. In order to find duplicate records from table we can use GROUP BY on all the fields and then use HAVING clause to return only those fields whose count…

Read more »

Login Page Coding

Table and form design: Default.aspx<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”login.aspx.cs” Inherits=”login” %> <!DOCTYPE html> <html xmlns=”http://www.w3.org/1999/xhtml”><head runat=”server”>    <title></title></head><body>    <form id=”form1″ runat=”server”>    <div>               …

Read more »

Insert, Delete and Update in Grid View

Table: Default.aspx <%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default8.aspx.cs” Inherits=”Default8″ %> <!DOCTYPE html> <html xmlns=”http://www.w3.org/1999/xhtml”><head runat=”server”>    <title></title></head>  <body>    <form id=”form1″ runat=”server”>    <div>        <asp:GridView ID=”GridView1″ runat=”server” AutoGenerateColumns=”False”…

Read more »

Upload file or Image and save in a folder and Display in Grid View

Default.aspx: <%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”image_upload.aspx.cs” Inherits=”image_upload” %> <!DOCTYPE html> <html xmlns=”http://www.w3.org/1999/xhtml”><head runat=”server”>    <title></title></head><body>    <form id=”form1″ runat=”server”>    <div>          <asp:FileUpload ID=”FileUpload1″ runat=”server” Width=”292px” />&nbsp;&nbsp;&nbsp; …

Read more »

Three tier Architecture in ASP.NET

Table: Class File:using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Data;using System.Data.SqlClient;using System.Configuration;namespace nsemployees{    public interface intemp    {        Int32 eno { get; set; }        string…

Read more »

Addition in Grid View using Sql Query:

Addition in Grid View using Sql Query:Table Data:Here I create two tables department table and employee table: Queries can be used: select * from tbdep select * from tbemployee select…

Read more »