Column Test

  • I need to update several client databases.

    How do I check table x for a column z to determine if I need to ADD column z?

    In other words if column z does not exist, I want to ADD it to table x; if column z exists I want to bypass the ADD.

    Thanks in advance.

    Phil K

     

  • you may use the following command:

    if not exists (select * from information_schema.columns where table_name=<tbl_name> and column_name=<col_name&gt

    begin

    alter table table_name add col_name <type>

    end

    use it and ask if any problem.

     

     

Viewing 2 posts - 1 through 1 (of 1 total)

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