• There is a good rule - always use the fully qualified name. Especially when databases have a lot of schema and without any guarantee don't to have the similar object name in different schema.

    And just a little add

    against

    IF EXISTS (SELECT * FROM dbo.sysobjects WHERE name = 'DF_Product_Cost' AND type = 'D') and etc.

    you can use

    IF OBJECT_ID(N'[test].[DF_Product_Cost]',N'D') IS NOT NULL