The default constraint does not have any name.
IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'dbo' AND TABLE_NAME = 'tAccounting' AND COLUMN_NAME = 'CreatedDtm' AND DATA_TYPE = 'datetimeoffset') ALTER TABLE [dbo].[tAccounting] ADD [CreatedDtm] [datetimeoffset] (2) NOT NULL DEFAULT (GETDATE())
GO IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE PARENT_OBJ = OBJECT_ID(N'tAccountingDtl') AND NAME = 'DF_tAccountingDtl_CreatedDtm' AND type = 'D') ALTER TABLE [dbo].[tAccountingDtl] ADD CONSTRAINT [DF_tAccountingDtl_CreatedDtm] DEFAULT (getutcdate()) FOR [CreatedDtm] GO
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.