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

How to create table in SQL server?

To create a table in SQL Server, you can use SQL Server Management Studio (SSMS) or execute SQL commands using a query window. Here's a step-by-step guide on how to create a table:

Using SQL Server Management Studio (SSMS):

  1. Open SSMS and connect to your SQL Server instance.
  2. In the Object Explorer pane, expand the database where you want to create the table.
  3. Right-click on the "Tables" folder and select "New Table."
  4. A new query window will open with a template for creating a table.
  5. Define the columns of the table by specifying the column name, data type, and any additional constraints.

    For example:


    Replace "TableName" with the desired name for your table and define the columns according to your requirements.
  6. Optionally, you can specify constraints such as primary key, foreign key, unique, or check constraints on the columns.
    For example, to add a primary key constraint:


  7. Click the "Execute" button or press F5 to create the table.

Using SQL Commands:

  1. Open SSMS and connect to your SQL Server instance.
  2. Open a new query window by clicking "New Query" in the toolbar or pressing Ctrl+N.
  3. Execute the following SQL command to create a table:
    
    CREATE TABLE TableName
    (
        Column1 INT,
        Column2 VARCHAR(50),
        Column3 DATE
    );
    
    
    Replace "TableName" with the desired name for your table and define the columns according to your requirements.
  4. Optionally, you can specify constraints such as primary key, foreign key, unique, or check constraints on the columns.
    For example, to add a primary key constraint:
    
    CREATE TABLE TableName
    (
        Column1 INT PRIMARY KEY,
        Column2 VARCHAR(50),
        Column3 DATE
    );
    
    
  5. Execute the query by clicking the "Execute" button or pressing F5 to create the table.

After executing the command or completing the steps, the table will be created in the specified database. You can then start inserting data into the table or modify it as needed using SQL commands or SSMS.