|
--script out recreation of calculated columns
insert into #sql
select 'ALTER TABLE ['+u.name+'].['+o.name+'] ADD ['+c.name+'] AS '+c.definition + case when c.is_persisted =1 then ' PERSISTED' else '' end + case when c.is_nullable = 0 then ' NOT NULL ' else '' end
from sys.computed_columns c
join sys.objects o
on c.object_id = o.object_id
join sys.schemas u
on u.schema_id = o.schema_id
where o.type ='U'
and objectproperty(o.object_id,'IsMSShipped')=0
and objectproperty(c.object_id,'IsTable')=1
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.