You must Sign In to post a response.
  • Category: SQL Server

    How to update column data

    Are you trying to update single column of your database table but confuse how to do? Read this thread and get detailed information.

    How to update a single column data while doing updation?
  • #732297
    Hi Namrata,

    Update Your_table_Name Set Your_Column_Name='' where Your_Column_Name=''


    Update Employee Set Name='Charles' where id=1001


  • #732299
    Thanx Sir

  • #732300
    Hi Namrata,

    Try something like below to achieve your goal.

    update table_name set col1='hello'
    where conditions

    This is common syantax, if you search in google you may get no.of results, why can't you are not search in google. First off all try to search by your self that is good practise to learn any technology.

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • #732313
    Hi Namratha,
    This is one of the basic commands of SQL.

    First try to go through the basics of SQL statements and try few examples searching them on google.

    Any way the solution provided by the above members are apt.

    Here is one of the best links for the starters to learn SQL:

    Hope it helps you and best of luck

    Thanks & Regards,
    Software Engineer.

  • #732343
    You can use this statement to update column data in SQL Server
    With Cte As (select Row_number() Over(partition By Col1 Order By Col1 Asc)as Row ,col1 From Tablename)
    Update Cte Set Col1=a.col1 From Table2 A Where Cte.row=a.col1;

  • #732362

    Using update query you can update the specific column values with the help of primary key value.

    You can try the following code.

    SqlConnection con = new SqlConnection("Data Source=datasourcename;Initial Catalog=databasename; user id=username; password=passwordvalue");
    SqlCommand com = new SqlCommand("update table set columname='"+columnvalue + "' where primarykeycolumnname='" + columnvalue + "'", con);
    int result = com.ExecuteNonQuery();
    //ExecuteNonquery will return either one or zero integer based on the query, if it is affected it will return one or else it will return zero
    return result;

    Hope it will be useful.

    Senior Software Engineer,
    Microsoft Certified Technology Specialist.

  • #735444
    update test set productame='fdfd' where productid=10001

    hope this i will help...

  • Sign In to post your comments