Tuesday, April 26, 2016

C# for Save and Retrive Data





using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;



 public partial class GridviewSample : System.Web.UI.Page
    {
        //string strConnString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conString"].ConnectionString);
        //SqlConnection con = new SqlConnection();
        SqlCommand cmd = new SqlCommand();
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //Page.Request.Form["datepickernm"] = "10/12/2015";
                txtCustomerName.Focus();
                if (!IsPostBack)
                {
                    FillGrid();
                }
            }
            catch
            {

            }

        }

        void FillGrid()
        {
            try
            {
            //    con = new SqlConnection(strConnString);
                cmd = new SqlCommand();
                cmd.CommandText = "Select CustomerID,CustomerName,PhoneNumber,Address,dob from tblCustomers where IsActive=1";
                cmd.Connection = con;
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                da.Fill(ds);
                gvDepartments.DataSource = ds;
                gvDepartments.DataBind();
            }
            catch
            {

            }
        }

        void ClearControls()
        {
            try
            {
                txtCustomerName.Text = "";
                txtPhoneNumber.Text = "";
                txtAddress.Text = "";
                hidCustomerID.Value = "";
                btnSave.Visible = true;
                btnUpdate.Visible = false;
                rbMale.Checked = false;
                rbFemale.Checked = false;
            }
            catch
            {

                throw;
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string text = datepicker.Value;
                

                string gender = string.Empty;
                Int16 val = 0;

                if (rbMale.Checked)
                {
                    gender = "1";
                    val = Int16.Parse(gender);
                }
                else {
                    gender = "2";
                    val = Int16.Parse(gender);
                }

                //con = new SqlConnection(strConnString);
                cmd = new SqlCommand();
                cmd.CommandText = "insert into tblCustomers (CustomerName,PhoneNumber,Address,IsActive,dob,gender) values (@CustomerName,@PhoneNumber,@Address,1,@dob,@gender)";
                cmd.Parameters.AddWithValue("@CustomerName", txtCustomerName.Text);
                cmd.Parameters.AddWithValue("@PhoneNumber", txtPhoneNumber.Text);
                cmd.Parameters.AddWithValue("@Address", txtAddress.Text);
                cmd.Parameters.AddWithValue("@dob", text);
                cmd.Parameters.AddWithValue("@gender", val);
                cmd.Connection = con;
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
                FillGrid();
                ClearControls();
                lblMessage.Text = "Saved Successfully.";
            }
            catch
            {

            }
            finally
            {
                if (con.State == ConnectionState.Open)
                    con.Close();
            }
        }

        protected void btnClear_Click(object sender, EventArgs e)
        {
            try
            {
                ClearControls();
            }
            catch
            {

            }
        }

        protected void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                string textdate;
                ClearControls();
                Button btn = sender as Button;
                GridViewRow grow = btn.NamingContainer as GridViewRow;
                hidCustomerID.Value = (grow.FindControl("lblCustomerID") as Label).Text;
                txtCustomerName.Text = (grow.FindControl("lblCustomerName") as Label).Text;
                txtPhoneNumber.Text = (grow.FindControl("lblPhoneNumber") as Label).Text;
                txtAddress.Text = (grow.FindControl("lblAddress") as Label).Text;
                textdate = (grow.FindControl("lblDOB") as Label).Text;
                var i = rbMale.Checked;
                var j = rbMale.Text;
                if (rbMale.Checked == true)
                {
                    rbMale.Checked = true;
                }
                else {
                    rbFemale.Checked = true;
                }
                
                datepicker.Value = textdate;
                btnSave.Visible = false;
                btnUpdate.Visible = true;
            }
            catch
            {

            }
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                String text = Page.Request.Form["datepickernm"];
          //      con = new SqlConnection(strConnString);
                cmd = new SqlCommand();
                cmd.CommandText = "update tblCustomers set CustomerName=@CustomerName,PhoneNumber=@PhoneNumber,Address=@Address,dob=@date where CustomerID=@CustomerID";
                cmd.Parameters.AddWithValue("@CustomerName", txtCustomerName.Text);
                cmd.Parameters.AddWithValue("@PhoneNumber", txtPhoneNumber.Text);
                cmd.Parameters.AddWithValue("@Address", txtAddress.Text);
                cmd.Parameters.AddWithValue("@CustomerID", hidCustomerID.Value);
                cmd.Parameters.AddWithValue("@date", text);
                cmd.Connection = con;
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
                FillGrid();
                ClearControls();
                lblMessage.Text = "Updated Successfully.";
            }
            catch
            {

            }
            finally
            {
                if (con.State == ConnectionState.Open)
                    con.Close();
            }
        }

        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
               // con = new SqlConnection(strConnString);
                ClearControls();
                Button btn = sender as Button;
                GridViewRow grow = btn.NamingContainer as GridViewRow;
                cmd = new SqlCommand();
                cmd.CommandText = "update tblCustomers set IsActive=0 where CustomerID=@CustomerID";
                cmd.Parameters.AddWithValue("@CustomerID", (grow.FindControl("lblCustomerID") as Label).Text);
                cmd.Connection = con;
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
                FillGrid();
                lblMessage.Text = "Deleted Successfully.";
            }
            catch
            {

            }
            finally
            {
                if (con.State == ConnectionState.Open)
                    con.Close();
            }
        }
    }






client side coding





<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GridviewSample.aspx.cs" Inherits="hailsap.GridviewSample" %>



<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">
        
  <meta charset="utf-8" />  
  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" />
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css" />
  <script>
      $(function () {
          $("#datepicker").datepicker();
      });
  </script>

    <title>Gridview Basics example.</title>
    <style type="text/css">
        .gv
        {
            font-family: Arial;
            margin-top: 30px;
            font-size: 14px;
        }
        .gv th
        {
            background-color: #5D7B9D;
            font-weight: bold;
            color: #fff;
            padding: 2px 10px;
        }
        .gv td
        {
            padding: 2px 10px;
        }
        input[type="submit"]
        {
            margin: 2px 10px;
            padding: 2px 20px;
            background-color: #5D7B9D;
            border-radius: 10px;
            border: solid 1px #000;
            cursor: pointer;
            color: #fff;
        }
        input[type="submit"]:hover
        {
            background-color: orange;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table align="center" style="position: relative; top: 20px;">
            <tr>
                <td>
                    <table align="center">
                        <tr>
                            <td>
                                Customer Name :
                            </td>
                            <td>
                                <asp:TextBox ID="txtCustomerName" runat="server" MaxLength="50" Width="250px"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Phone Number :
                            </td>
                            <td>
                                <asp:TextBox ID="txtPhoneNumber" runat="server" MaxLength="10" Width="250px"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Address :
                            </td>
                            <td>
                                <asp:TextBox ID="txtAddress" runat="server" MaxLength="200" Width="250px"></asp:TextBox>
                            </td>
                        </tr>
                          <tr>
                            <td>
                                Date :
                            </td>
                            <td>
                                <input type="text" runat="server" id="datepicker" name="datepickernm"/>
                            </td>
                        </tr>    
                         <tr>
                            <td>
                                Gender :
                            </td>
                            <td>
                                <asp:RadioButton ID="rbMale" Text="Male" runat="server" GroupName="Gender" />
                                <asp:RadioButton ID="rbFemale" Text="Female" runat="server" GroupName="Gender" />
                            </td>
                        </tr>                     
                        <tr>
                            <td colspan="2" align="center">
                                <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" />
                                <asp:Button ID="btnUpdate" runat="server" Text="Update" OnClick="btnUpdate_Click"
                                    Visible="false" />
                                <asp:Button ID="btnClear" runat="server" Text="Clear" OnClick="btnClear_Click" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td align="center">
                    <br />
                    <asp:Label ID="lblMessage" runat="server" EnableViewState="false" ForeColor="Blue"></asp:Label>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:GridView ID="gvDepartments" runat="server" AutoGenerateColumns="False" ShowHeaderWhenEmpty="True"
                        EmptyDataText="No Records Found" GridLines="both" CssClass="gv" EmptyDataRowStyle-ForeColor="Red">
                        <Columns>
                            <asp:TemplateField HeaderText="Customer Name">
                                <ItemTemplate>
                                    <asp:Label ID="lblCustomerName" runat="server" Text='<%#Eval("CustomerName") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Phone Number">
                                <ItemTemplate>
                                    <asp:Label ID="lblPhoneNumber" runat="server" Text='<%#Eval("PhoneNumber") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Address">
                                <ItemTemplate>
                                    <asp:Label ID="lblAddress" runat="server" Text='<%#Eval("Address") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                              <asp:TemplateField HeaderText="Date of Birth">
                                <ItemTemplate>
                                    <asp:Label ID="lblDOB" runat="server" Text='<%#Eval("dob") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Action">
                                <ItemTemplate>
                                    <asp:Button ID="btnEdit" runat="server" Text="Edit" OnClick="btnEdit_Click" />
                                    <asp:Button ID="btnDelete" runat="server" Text="Delete" OnClientClick="return confirm('Are you sure? want to delete the department.');"
                                        OnClick="btnDelete_Click" />
                                    <asp:Label ID="lblCustomerID" runat="server" Text='<%#Eval("CustomerID") %>' Visible="false"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                </td>
            </tr>
        </table>
        <input type="hidden" runat="server" id="hidCustomerID" />
    </div>        
    </form>
</body>
</html>

Sunday, August 16, 2015

Windows 10 gets third ‘cumulative update’ since launch

Microsoft has adopted a new mechanism to roll out updates since the launch of Windows 10 that was released on July 29.
In its third update since launch, Microsoft has begun the rollout of what it calls a cumulative update. This means that the update file is cumulative. In case you haven’t installed the earlier updates, this updates gets you up and running with the latest version of Windows.
On the other hand, if you have updated the prior updates, then only incremental patches are installed.
In a post on ZDNet, Mary Jo Foley has said, “But a Microsoft spokesperson did let me know that the new update is designed to fix the Windows 10 Store issues which had been affecting a number of us Windows 10 users for the past week. A number of us were unable to access the Store, obtain app updates and/or download new apps. In some cases, Windows Store apps like Mail and Calendar were also not working.”

She adds, “‘KB 3081438 is now available resolving the Store issues,’ said the spokesperson in response to my question about what Microsoft was doing to fix the Store issues. Company officials declined to say anything beyond that about what specifically caused the Store problems. I was told ‘Microsoft has nothing further to share.’”
In its official update, Microsoft said, “This update includes improvements to enhance the functionality of Windows 10. Windows 10 updates are cumulative. Therefore, this package contains all previously released fixes. If you have previous updates installed, only the new fixes that are contained in this package will be downloaded and installed to your computer.”



Tuesday, February 10, 2015

Common Network Hacking Techniques

Common Network Hacking Techniques

Hacking on computer networks is often done through scripts or other network programming. These programs generally manipulate data passing through a network connection in ways designed to obtain more information about how the target system works. Many such pre-packaged scripts are posted on the Internet for anyone, typically entry-level hackers, to use. More advanced hackers may study and modify these scripts to develop new methods. A few highly skilled hackers work for commercial firms with the job to protect that company's software and data from outside hacking.


Cracking techniques on networks include creating worms, initiating DOS attacks, or in establishing unauthorized remote access connections to a device.

Tuesday, July 15, 2014

Views

Introduction:
In this article we are going to discuss about the Views in the sql server 2005 version. It is one of the important elements in the sql server; it eliminates the difficulties in the business process. There are lots of significant improvements in the view especially in the sql server 2005 version. They have introduced the indexed views and INSTEAD of Trigger on the permanent view. Let us discuss about the views with more practical way.

Views:

The view is a virtual table, which can have the multiple columns from the one or more table. It can be used like the normal table. Normally view cannot store the data permanently in the table. When we create the view it stores the view definition schema as object under the concern database.

Let us see the syntax of the create view

CREATE VIEW View Name [Alias name1, name2,]

WITH ENCRYPTION

WITH SCHEMA BINDING

AS

SELECT statement [WITH CHECK OPTION]

The create view can be created with the view name and the alias can be given in the view name parameter parenthesis. The view schema can be stored in the encrypted format. Here is an option like SCHEMA BINDING; this is an important mile stone in the view to allow the developers to create the permanent view.

When to use VIEW?

When you have complex queries, that use many places in the stored procedures or functions, etc..,

It will be used as security mechanism in the web applications. When we use the original table in the web applications the hackers may drop the table. That time the original data will be persist in the table.

When you want to hide the particular columns to the specific people then we can create the specialized view.

Encrypted View:

The definition of schema will be encrypted and stored as object in the database. This can be done using the ENCRYPTION option in the view creation.

IF
 OBJECT_ID('[DBO].Vw_SqlObjects_Encrypted') IS NOT NULLBEGIN   DROP VIEW [DBO].Vw_SqlObjects_Encrypted   PRINT '<< [DBO].Vw_SqlObjects_Encrypted View dropped >>'ENDGOCREATE VIEW [DBO].Vw_SqlObjects_EncryptedWITH ENCRYPTIONAS   SELECT       O.Object_ID      ,O.Name      ,'Type' = CASE O.type WHEN 'S' THEN 'Scalar Functions'                          WHEN 'F' THEN 'Functions'                          WHEN 'V' THEN 'Views'                          WHEN 'PK' THEN 'Primary keys'                          WHEN 'TR' THEN 'Triggers'                          WHEN 'P' THEN 'Procedures'                          WHEN 'U' THEN 'User Defined Functions'                          WHEN 'TF' THEN 'Table Valued Functions'                          WHEN 'IF' THEN 'Inline Functions' END      ,O.create_date      ,O.modify_date      ,CASE WHEN SC.encrypted = 0 THEN 'No' ELSE 'Yes' END AS [IsEncrypted]      ,SC.text  FROM      SYS.OBJECTS O  INNER JOIN      SYSCOMMENTS SC ON SC.id = O.object_id  GOIF OBJECT_ID('[DBO].Vw_SqlObjects_Encrypted') IS NOT NULLBEGIN   PRINT '<< [DBO].Vw_SqlObjects_Encrypted View created >>'ENDGO
Now if you want to see the view schema definition for the above view is not possible. We have stored in the encrypted format. This is a significant option to hide the important calculations inside the view from the others.

In case of any alter in the view must be stored externally somewhere else. 

SELECT
 text FROM SYSCOMMENTS WHERE id = OBJECT_ID('[DBO].Vw_SqlObjects_Encrypted')
SELECT definition FROM SYS.sql_modules WHERE object_id =OBJECT_ID('[DBO].Vw_SqlObjects_Encrypted')
sp_helptext Vw_SqlObjects_Encrypted
If you execute the above queries then it will say like view is encrypted.

There are three types of views in the sql server 2005.

They are 
  1. Normal or Standard view
  2. Indexed or permanent view
  3. Partitioned view
Normal or Standard view:
This view is most frequently used by the developers. When create the view the schema will be stored an object in the database. When we retrieve the content from this virtual table, it will be executed the schema and stored the data from the parent table.

Here if you have the result from the same table then it can be updated and inserted. The deleted row will be reflected in the original table.

USE
 [Northwind]GOIF OBJECT_ID('[DBO].vw_ViewProducts','V') IS NOT NULLBEGIN  DROP VIEW [DBO].vw_ViewProducts  PRINT '<< [DBO].vw_ViewProducts view dropped.. >>'ENDGOCREATE VIEW [DBO].vw_ViewProductsAS SELECT     ProductID,ProductName,SupplierID,CategoryID,QuantityPerUnit,UnitPrice,UnitsInStock,
UnitsOnOrder,ReorderLevel,Discontinued
 FROM ProductsGOIF OBJECT_ID('[DBO].vw_ViewProducts','V') IS NOT NULLBEGIN  PRINT '<< [DBO].vw_ViewProducts view created.. >>'ENDGO--O/PSELECT * FROM [DBO].vw_ViewProducts--INSERTINSERT INTO[DBO].vw_ViewProducts(ProductName,SupplierID,CategoryID,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued)VALUES('Test View',1,2,'100 per bag',25.45,89,57,15,0)--DELETEDELETE FROM [DBO].vw_ViewProducts WHERE ProductID = 81
Here you can do the DML operations in the view when you have only one table. 

Indexed views:

The indexed or permanent view is one of the new features introduced in the sql server 2005 version. We have seen that the view only store the schema definition and it will get execute and load the data into the virtual table at the time of view used. But this view creates the permanent view and we can create the indexes on the table. It allows us to create the instead of trigger.

The indexed view can be created with the WITH SCHEMA BINDING option while creating the view.

The indexed view has some restrictions like cannot use the TOP, DISTINCT, UNION, ORDER BY and aggregate functions.

It allows us to use the GROUP BY statement but we cannot use COUNT statement. Instead of that COUNT_BIG statement can be used.

IF
 EXISTS(SELECT OBJECT_ID FROM SYS.OBJECTS WHERE OBJECT_ID =OBJECT_ID(N'[DBO].Vw_Product_Sales_Report',N'V'))BEGIN  DROP VIEW [DBO].Vw_Product_Sales_Report  PRINT '<< [DBO].Vw_Product_Sales_Report view dropped >>'ENDGOCREATE VIEW [DBO].Vw_Product_Sales_ReportWITH SCHEMABINDINGAS  SELECT       O.OrderID     ,C.CustomerID     ,C.CompanyName     ,C.Address+', '+C.City AS [Customer Address]     ,OD.ProductID     ,P.ProductName     ,OD.UnitPrice     ,OD.Quantity     ,(OD.UnitPrice * OD.Quantity) AS [Total]     ,(OD.UnitPrice * OD.Quantity) * OD.Discount/100 AS [Discount]   FROM     [DBO].Orders O (NOLOCK)   INNER JOIN [DBO]."Order Details" OD (NOLOCK) ON OD.OrderID = O.OrderID   INNER JOIN [DBO].Customers C (NOLOCK) ON C.CustomerID = O.CustomerID   INNER JOIN [DBO].Products P (NOLOCK) ON P.ProductID = OD.ProductIDGOIF EXISTS(SELECT OBJECT_ID FROM SYS.OBJECTS WHERE OBJECT_ID =OBJECT_ID(N'[DBO].Vw_Product_Sales_Report',N'V'))BEGIN  PRINT '<< [DBO].Vw_Product_Sales_Report view created >>'ENDGO
Here the  indexed view has created. When you retrieve the data from this table, it will execute like normal table.

There are some retrictions while creating this indexed view like the name of the view must be two part name and we cannot use select * in the view schema defintion.

Normally view cannot have the triggers but from the sql server 2005 onwards We can create the Instead of trigger on the instead of trigger.

Partitioned Views:

The partitioned view and its execution is like normal view. It will work across the database and across the server.

There are two types of Partitioned views. They are 
  1. Local Partitioned View
  2. Global Partitioned View

1. Local Partitioned View:
The local partitioned view can be created within same server but different database.

The view schema definition will be stored in the executed database. But when we try to retrieve the data from the table, it has to execute the schema definition internally and load the data.

Let us see an example.

USE
 [Northwind]GOCREATE TABLE EmployeeList(  iEmployeeID INT IDENTITY(1,1),  vFirstName VARCHAR(25) NOT NULL,  vLastName VARCHAR(25) NOT NULL,  iDeptID INT,  vAddress VARCHAR(25) NOT NULL,  vCity VARCHAR(25) NOT NULL,  vState VARCHAR(25) NOT NULL,  vCountry VARCHAR(25) NOT NULL,)GOUSE [Master]GOCREATE TABLE Department(  iDeptID INT IDENTITY(1,1) PRIMARY KEY,  vDeptName VARCHAR(50),  vDeptDesc VARCHAR(25),  vDeptAddedBy VARCHAR(50),  vPostedDate DATETIME DEFAULT GETDATE())GO--SELECT * FROM DepartmentUSE [Northwind]GOIF OBJECT_ID('[DBO].vw_LocalPartion_View','V') IS NOT NULLBEGIN  DROP VIEW [DBO].vw_LocalPartion_View  PRINT '[DBO].vw_LocalPartion_View view dropped...'ENDGOCREATE VIEW [DBO].vw_LocalPartion_ViewASSELECT E.iEmployeeID,E.vFirstName+SPACE(1)+E.vLastName AS [Name],       D.vDeptName,E.vAddress,E.vCity,E.vStateFROM EmployeeList E--INNER JOIN Master..Department D ON D.iDeptID = E.iDeptID --Either one of the way will be used.INNER JOIN Master.dbo.Department D ON D.iDeptID = E.iDeptIDGOIF OBJECT_ID('[DBO].vw_LocalPartion_View','V') IS NOT NULLBEGIN  PRINT '[DBO].vw_LocalPartion_View view created...'ENDGO--O/pSELECT * FROM [DBO].vw_LocalPartion_View 

2. Global Partitioned View

The global Partitioned view will work across the server. The view can be created to join the table across the server.

The accessing format will be like this.

[Server Name].  Database Name. Table Name

When we execute the view if it is not linked with the current server then it will ask us to link the external server.

The following system stored procedure will be used to link the server.

sp_addlinkedserver 
'Server name'
The following system catalog table is used to see the list of linked servers.

SELECT
 * FROM SYS.SERVERS
INSTEAD OF Triggers on the Indexed View

Normally the triggers cannot be created on the view. But sql server 2005 onwards we can create the INSTEAD OF trigger on the indexed views.

USE
 [Northwind]GOIF OBJECT_ID('[DBO].[VW_Trigger_Example') IS NOT NULLBEGIN   DROP VIEW [DBO].[VW_Trigger_Example]   PRINT '[DBO].[VW_Trigger_Example view dropped..'ENDGOCREATE VIEW [DBO].[VW_Trigger_Example]WITH SCHEMABINDINGAS  SELECT P.ProductID,P.ProductName,P.SupplierID,         OD.OrderID,OD.UnitPrice,OD.Quantity  FROM [DBO].Products P  INNER JOIN [DBO].[Order Details] OD ON OD.ProductID = P.ProductIDGOIF OBJECT_ID('[DBO].[VW_Trigger_Example') IS NOT NULLBEGIN   PRINT '[DBO].[VW_Trigger_Example view created..'ENDGO--SELECT * FROM VW_Trigger_ExampleIF OBJECT_ID('[DBO].Tr_Delete_TriggerExample','TR') IS NOT NULLBEGIN  DROP TRIGGER [DBO].Tr_Delete_TriggerExample  PRINT '[DBO].Tr_Delete_TriggerExample trigger dropped..'ENDGOCREATE TRIGGER [DBO].Tr_Delete_TriggerExampleON [DBO].VW_Trigger_ExampleINSTEAD OF DELETEASBEGIN   PRINT '----------------------------------------'   PRINT 'This is an example of INSTEAD OF Trigger'   PRINT '----------------------------------------'   SELECT TOP 1 * FROM DELETEDENDGOIF OBJECT_ID('[DBO].Tr_Delete_TriggerExample','TR') IS NOT NULLBEGIN  PRINT '[DBO].Tr_Delete_TriggerExample trigger created..'ENDGO--O/P--SELECT * FROM [DBO].[VW_Trigger_Example] WHERE ProductID = 11DELETE FROM [DBO].[VW_Trigger_Example] WHERE ProductID=11
How to view the Created Views?

There are few ways to view the scehema definition of the created views.

SP_HELPTEXT
 vw_LocalPartion_ViewSELECT id,text FROM SYSCOMMENTS WHERE id = OBJECT_ID('[DBO].vw_LocalPartion_View')SELECT object_id,definition FROM SYS.SQL_MODULES WHERE OBJECT_ID =OBJECT_ID('[DBO].vw_LocalPartion_View')
How to drop the View?

If you want to drop the view then you can use the following statement. When you drop the table underlying view will not be deleted. But if you run that view it will thrown an error.

DROP VIEW VIEW_NAME

How to alter the view?

If you want to do changes in the created views then you can alter the view whatever you want to view the same view name.

ALTER VIEW VIEW_NAME
AS
SELECT [Columns List]....
Conclusion:

So far, we have seen the views in the sql server 2005. I hope that, this has given enough idea about the views. If there is any correction or suggestions about this article please post your feedback.