if not exists (select name from dbo.sysobjects where name='fGetCirculationOfGood') begin exec('create FUNCTION dbo.fGetCirculationOfGood() returns @tbl table(ID int) as begin return end') end