Update Query

  • how to update all field in a table with same data without all column name

    because my table have 110 column

    plz help me out..

  • You don’t have to specify all the columns’ names. You have to specify only the names of the columns that you want to update. If you are going to update all the columns, then you’ll have to specify the names of all the columns. This is very basic staff and if you are working with SQL, I suggest that you’ll read about select, update, insert and delete statement.

    Adi

    --------------------------------------------------------------
    To know how to ask questions and increase the chances of getting asnwers:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • Hi adi,

    thanks for rply

    i know that if we write the all column names then it will work

    but dnt want to use that column name because its near abt 110 column.

    and i think i wrote all the column name then that query is created very big.

    i dnt want this.there for i m asking any another query for that.

  • and i want to update all column with same value.

  • You have to use all the column names.

    In management studio, if you right click on the table name, select 'Script Table as' and 'Update', then the column names will be generated for you.

  • Hi Ken,

    ohh its good idea i never thought this idea.

    thanks for u r suggestion.

  • I am not sure if this will work for you, but I once did somethign similar for someone, I dumped all the field names for a table into a temp table, based on a select out of sysobjects and syscolumn if I remember correctly, then built a SQL string statement and used EXEC to push the update to all fields without having to hardcode all the field names.

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply