I would like to run the “Change Table” in ALL tables in my SQL file:
ALTER TABLE test ADD CONSTRAINT [COLLUM_NAME] DEFAULT ((0)) FOR [COLLUM_NAME]
I know how to get all existing tables from a database:
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'
or
USE DATABASE_NAME GO SELECT name FROM sys.Tables GO
But I do not know how to combine these two.
In my database (50+ tables) all tables have one common row. and I would like to set a default value for all these lines.
source share