Forum Discussion

Bhavsing's avatar
Bhavsing
Copper Contributor
Mar 01, 2023

update the records

Hi Team, This is Bhavsing, I'm new learner of the SQL Server,  I have one small doubt that if while we have a all rows with same value then how do we update a different values.     Coul...
  • HarshKumar994's avatar
    Mar 01, 2023

    Bhavsing 

    Its better to have an identity column or a column with a Primary key.

     

    Identity Column -> In SQL Server, an identity column is a special type of column that is commonly used as the primary key of a table. An identity column is a column whose values are generated automatically by the database system, typically incrementing by 1 for each new row added to the table. The purpose of an identity column is to provide a unique, sequential number for each row in the table.

     

    Example -

    CREATE TABLE my_table (
    id INT IDENTITY(1,1) PRIMARY KEY,
    name VARCHAR(50),
    age INT
    );

     

    Update Statement -
    UPDATE my_table
    SET my_column = 'new_value'
    WHERE my_column = 'old_value';

     

    You can manually update the same via GUI as well.

     

     

    Hope it's clear------- If yes, reply and hit like ----- If not reply with your query in more detail----

     

Share

Resources