Share via

UDF disappearing after backup database sql server

Zokir Sobirjonov 1 Reputation point
2022-08-09T07:25:03.887+00:00

Hi. A have a database. After backup I cannot find User Defined Functions. How can I solve it?

SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories


2 answers

Sort by: Most helpful
  1. Erland Sommarskog 134.7K Reputation points MVP Volunteer Moderator
    2022-08-09T21:56:40.093+00:00

    My guess is that you had created the function inside a transaction which you had not committed. When the other dev restarted SQL Server, the transaction was rolled back.

    Was this answer helpful?

    0 comments No comments

  2. Seeya Xi-MSFT 16,756 Reputation points
    2022-08-09T08:32:13.097+00:00

    Hi @Zokir Sobirjonov ,

    Welcome to Microsoft Q&A!
    Firstly, you can use the following script to check if the UDF is gone:

    SELECT  
         name AS 'Function Name',  
         SCHEMA_NAME(schema_id) AS 'Schema',  
         type_desc AS 'Function Type',   
         create_date AS 'Created Date'  
    FROM  
         sys.objects  
    WHERE  
         type in ('FN', 'IF', 'FN', 'AF', 'FS', 'FT');  
    

    Yes. As TiborKaraszi said, > That shouldn't happen either.
    You can use DBCC CHECKDB to check is the database corrupted.
    If there is any corruption, you can restore another good backup. If you don't have a good backup, consider using the DBCC CHECKDB option REPAIR_ALLOW_DATA_LOSS. Of course, in order to prevent data loss, the best option is to restore a new good backup.

    Best regards,
    Seeya


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.