IF NOT EXISTS (SELECT * FROM SYSCOLUMNS INNER JOIN SYSOBJECTS ON SYSOBJECTS.id = SYSCOLUMNS.id 
               WHERE SYSCOLUMNS.NAME = 'TKIPTAL' AND SYSOBJECTS.name = 'HTETKIKKART')
ALTER TABLE dbo.HTETKIKKART ADD 
	TKIPTAL bit NULL 

GO

WHILE EXISTS(SELECT TOP 1 * FROM HTETKIKKART WHERE TKIPTAL IS NULL)
BEGIN
UPDATE TOP (3000) HTETKIKKART 
	SET TKIPTAL = 0
	WHERE TKIPTAL IS NULL 
END


IF NOT EXISTS (
select * from syscolumns inner join 
     sysobjects on syscolumns.id = sysobjects.id inner join
     sysconstraints on constid = syscolumns.cdefault 
where sysobjects.name = 'HTETKIKKART' and syscolumns.name='TKIPTAL')
	ALTER TABLE HTETKIKKART ADD  CONSTRAINT DF_HTETKIKKART_TKIPTAL  DEFAULT ((0)) FOR TKIPTAL 
GO


IF EXISTS (SELECT * FROM SYSCOLUMNS INNER JOIN SYSOBJECTS ON SYSOBJECTS.id = SYSCOLUMNS.id 
               WHERE SYSCOLUMNS.NAME = 'TKIPTAL' AND SYSOBJECTS.name = 'HTETKIKKART')
ALTER TABLE dbo.HTETKIKKART ALTER COLUMN
	TKIPTAL bit NOT NULL 

GO

