Reputation: 339
I have a column called 'LastModifiedDate' of 'smalldatetime' data type.
This column is present in almost all of my tables in the database.
I want to change this column to 'datetime' data type.
Is there any way to do that with a sql script?
Upvotes: 1
Views: 65
Reputation: 204784
To generate a script you could do
SELECT
'ALTER TABLE [' + Table_Schema + '].[' + Table_Name + '] ' +
'ALTER COLUMN [' + Column_Name + '] DATETIME;'
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME = 'LastModifiedDate'
Upvotes: 2