IF NOT EXISTS (SELECT * FROM SYSCOLUMNS INNER JOIN SYSOBJECTS ON SYSOBJECTS.id = SYSCOLUMNS.id 
              WHERE SYSCOLUMNS.NAME = 'SUBEID' AND SYSOBJECTS.name = 'TMDLORNEKDOSYATUR')
ALTER TABLE dbo.[TMDLORNEKDOSYATUR] ADD SUBEID INT  NULL

GO

--SELECT * FROM TMDLORNEKDOSYATUR
UPDATE TMDLORNEKDOSYATUR SET SUBEID=(SELECT MIN(SUBEID) FROM SUBELER )  WHERE SUBEID IS NULL
GO