How to Add column to multiple table using single script ?

  • Hi All,

    I am looking a script which allow me add single coilumn to multiple table of my database.

    For Example :-

    I am having 4 table

    1-Emp , 2-Dept , 3-Location , 4-Salary like this I have around 100 of table

    Now I want to run below command to add column Rowchecksum in all table where table name start with Archivebbx keywords.

    Alter table EMP

    Add Rowchecksum varbinary(8000)

    Please help me with the correct code .

    Thanks in Advance

    Regards,

    Vipin Jha

  • You can use below script to generate the script to add column.

    SELECT 'Alter table [' +name + '] Add Rowchecksum varbinary(8000)' FROM sys.tables WHERE name LIKE 'Archivebbx%'

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

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