TSQL delete function if it already exists


/ Published in: SQL
Save to your folder(s)



Copy this code and paste it in your HTML
  1. IF EXISTS (
  2. SELECT 1 FROM INFORMATION_SCHEMA.ROUTINES
  3. WHERE ROUTINE_NAME = 'fn_MyFunction'
  4. AND ROUTINE_SCHEMA = 'dbo'
  5. AND ROUTINE_TYPE = 'FUNCTION'
  6. )
  7. BEGIN
  8. DROP FUNCTION dbo.fn_MyFunction
  9. PRINT 'Dropped dbo.fn_MyFunction'
  10. END

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.