Showing posts with label Function. Show all posts
Showing posts with label Function. Show all posts

Monday, June 14, 2010

Check and drop existing function in SQL database

Check if function exists in SQL server, and drop it if required.

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[FN_Name]') AND xtype in (N'FN', N'IF', N'TF'))

BEGIN

DROP FUNCTION [dbo].[FN_Name]

END