
DECLARE @SUBEID nvarchar(20)

SELECT TOP 1 @SUBEID = SUBEID FROM SUBELER WHERE MEDISOFT = 1

IF @SUBEID IS NULL
  SET @SUBEID = 1

UPDATE SAYACLAR SET [TABLENAME] = 'HASTAARSIV-'+@SUBEID 
WHERE [TABLENAME] = 'HKIMLIKARSIVSAYAC' AND NOT EXISTS (SELECT SIRANO FROM SAYACLAR WHERE [TABLENAME] = 'HASTAARSIV-'+@SUBEID)
GO


