20 lines
624 B
Transact-SQL
20 lines
624 B
Transact-SQL
use envisage
|
|
|
|
IF exists (select 1 from sys.columns where name like 'Priority' and object_id = OBJECT_ID('Scenario'))
|
|
BEGIN
|
|
ALTER TABLE Project
|
|
ADD [Priority] int not null constraint df_priority1 default 1
|
|
|
|
ALTER TABLE Project drop constraint df_priority1
|
|
END
|
|
GO
|
|
IF exists (select 1 from sys.columns where name like 'Priority' and object_id = OBJECT_ID('Scenario'))
|
|
BEGIN
|
|
UPDATE Project SET [Priority] = ISNULL ((select top 1 [Priority] from Scenario where Scenario.ParentId = Project.Id order by [Status] desc), 1)
|
|
|
|
ALTER TABLE Scenario
|
|
DROP COLUMN [Priority]
|
|
|
|
ALTER TABLE ScenarioCln
|
|
DROP COLUMN [Priority]
|
|
END |