SQL Server BasicsWhat is SQL Server database?What is RDBMS?What is Normalization?Why we use Denormalization?What_is_SQL?What is PL/SQL?Difference between SQL and PL/SQLDatabase TableOne to One RelationshipOne to Many RelationshipMany to Many RelationshipMany to One RelationshipString Data TypesNumber Data TypesDate Data TypesOther Data TypesCreate DatabaseDrop DatabaseCreating and Managing Users in SQL ServerCreate TableAlter TableDrop TableConstraints in SQL serverPrimary KeyForeign KeyUnique KeyCandidate KeyComposite KeyDifference between primary key and candidate keyPrimary key and foreign key relationshipSurrogate KeyCascading Referential Integrity ConstraintsSelf Referential Integrity ConstraintsInsert into statementInsert multiple recordsUpdate statementDelete statementTruncate statementDifference between Delete and TruncateAlias in SQL ServerSelect statementSelect DistinctSelect TopSelect IntoNull Functions(ISNULL(),NULLIF(),COALESCE())Sub QueryIdentity ColumnSequence objectDifference between sequence and identity columnSQL Server ClausesWHERE ClauseOrder By ClauseTop N ClauseGroup By ClauseHaving ClauseDifference between Where and HavingSQL Server OperatorsArithmetic OperatorsComparison OperatorsLogical OperatorsBitwise OperatorsAny OperatorsAll OperatorsUnion OperatorsUnion All OperatorsDifference between Union and Union AllIntersect OperatorExcept OperatorDifference between Except and IntersectJoinsInner JoinLeft JoinRight JoinFull JoinSelf JoinCross JoinViewsWhat are views?Create views using SSMSIndexed ViewsComplex ViewsCheck Option in ViewCheck Encryption in ViewSchema Binding Option in ViewRead-only ViewsUpdatable ViewsAdvantages and disadvantages of viewsCreate multiple views on one tableCan we implement index on views?Can we Perform Insert, update, delete operation on views?Stored Procedure and FunctionsWhat are Stored Procedures?Why we use stored procedures?Passing parameters to Stored procedureUser-Defined FunctionsDifference between UDF and Stored procedurePre-Defined Functions@@Indentity and Scope_IndentityNULLIF, ISNULL and COALESCE

Can we create updateble view?

Yes, it is possible to create updatable views in SQL Server. Updatable views allow you to perform INSERT, UPDATE, and DELETE operations directly on the view, which in turn modifies the underlying tables.

To create an updatable view, you need to ensure that certain conditions are met:

  1. The view must reference a single base table. It cannot reference multiple tables or use complex expressions or joins.
  2. The view's SELECT statement must include all columns from the base table that are required for the update operation. This includes any primary key or unique constraint columns that are necessary for identifying rows during updates and deletes.
  3. The view must not contain any aggregate functions, DISTINCT, GROUP BY, UNION, or subqueries in the SELECT statement.
  4. The view must not include any computed columns or columns with expressions.

Here's an example of creating an updatable view:


CREATE VIEW UpdatableView
AS
SELECT Column1, Column2, ...
FROM TableName
WHERE Condition;

In this example, the "UpdatableView" is created as an updatable view. It selects columns from the "TableName" and applies a condition to filter the rows. As long as the above conditions are met, you can perform INSERT, UPDATE, and DELETE operations on this view, and the modifications will be reflected in the underlying table.

For example, you can perform an update operation on the view as follows:


UPDATE UpdatableView
SET Column1 = NewValue
WHERE Condition;

Similarly, you can perform INSERT and DELETE operations on the view.

It's important to note that while updatable views provide a convenient way to modify data, they have certain limitations and considerations. For example, complex views with multiple tables or complex expressions may not be updatable. Additionally, the view must not violate any integrity constraints, such as primary key or foreign key constraints, during data modifications.

Before using updatable views, it's recommended to thoroughly test and verify the behavior to ensure it meets your requirements and maintains data integrity.