Run Below query to generate script:
SELECT
'ALTER TABLE ' + TABLE_NAME + ' ALTER COLUMN Createdby varchar(50) ;' +
'ALTER TABLE ' + TABLE_NAME + ' ALTER COLUMN Updatedby varchar(50) ;' AS Script
FROM INFORMATION_SCHEMA.TABLES
Take care of following items:
- Above query generate scripts for all the tables which were created in that database, deleted tables are also included in it.
- If tables contains that field or not it will generate script for that table also. Manually you have to remove that table script to run the generated scripts.
- CreatedBy and UpdatedBy is the field name of the tables which I want to update.
- Above query generates script for 2 fields, if you want to increase or decrease you have to update above query as per your requirement.
Hello, I log on to your blogs on a regular basis.
ReplyDeleteYour story-telling style is witty, keep up the good work!