Updating column in a table

  • Can someone help me with an example of a quick script to update a column of a table that is a name field which was spelled wrongly. What I'm trying to say is I need a script that can change the miss typed name in the column in question. Any feedback greatly appreciated.

  • can someone tell me if the code below will update the table in question's column to the specified in SQL 6.5

    update tablename

    set columnname1 = 'Myname, Me'

    where

    columnname1 = 'Myname, me' and

    columntype = '1111' and

    columncode = '3'

    would the code above update the table with the new name Myname, Me?

    Prompt response really appreciated...

    cheers

     

  • now i have an obvious question which is i have to query each and every database for this name wherever it appears, and i'm sceptical about running a select statement on a database with different table sizes. The problem is nobody knows all the table where this individual exists so i have to query each and every database to extract this information before writing an update script to correct this. Any quicker way to this much appreciated...

  • I'm not sure if this works in 6.5 but the method I usually use is:

    sp_rename 'tablename.columnname', 'newcolumnname'

    To find out where the column exists in each database you clould use:

    SELECT name FROM sysobjects WHERE id IN(

    SELECT id FROM syscolumns WHERE name LIKE 'columnname')

    and xtype LIKE 'U'

     

    Good luck

    Craig

Viewing 4 posts - 1 through 3 (of 3 total)

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