IF NOT EXISTS (SELECT * FROM SYSCOLUMNS INNER JOIN SYSOBJECTS ON SYSOBJECTS.id = SYSCOLUMNS.id 
               WHERE SYSCOLUMNS.NAME = 'MIATSURESI' AND SYSOBJECTS.name = 'TKANBILESENI')
ALTER TABLE dbo.TKANBILESENI ADD
	MIATSURESI int NULL,
	MIATPERIYODU nvarchar(50) NULL
GO

DECLARE @sqlcmd      nvarchar(1000)
IF EXISTS (SELECT * FROM SYSCOLUMNS INNER JOIN SYSOBJECTS ON SYSOBJECTS.id = SYSCOLUMNS.id 
               WHERE SYSCOLUMNS.NAME = 'SKMIADGUNSAYISI' AND SYSOBJECTS.name = 'TKANBILESENI')
BEGIN
    SET @sqlcmd = 
    N'UPDATE TKANBILESENI
	SET MIATSURESI = SKMIADGUNSAYISI,
		MIATPERIYODU = N''GÜN''
	WHERE MIATSURESI IS NULL AND SKMIADGUNSAYISI IS NOT NULL'
	
	EXEC(@sqlcmd)

	ALTER TABLE dbo.TKANBILESENI DROP COLUMN
		SKMIADGUNSAYISI
END
GO