OBJECT_ID, system_function_schema

  • Hello,

    I got the following code snippet

    .

    .

    .

    IF EXISTS (SELECT *

    FROM dbo.SysObjects

    WHERE Id OBJECT_ID(N'[master].[system_function_schema].[fn_NulUniqueIdentifier]')

    AND xType IN (N'FN', N'IF', N'TF'))

    PRINT 'Ok'

    ELSE

    PRINT 'Nok'

    .

    .

    .

    When i run this code, it gives always not ok, even i know it exists. What do i wrong.

    Thanks in advice

    Johan

  • Hi

    There is a syntax error in your code , "=" is missing .

    IF EXISTS (SELECT *

    FROM dbo.SysObjects

    WHERE Id = OBJECT_ID(N'[master].[system_function_schema].[fn_NulUniqueIdentifier]')

    AND xType IN (N'FN', N'IF', N'TF'))

    PRINT 'Ok'

    ELSE

    PRINT 'Nok'.

    The object fn_NulUniqueIdentifier does not exist in the master database. That is why it returns "Nok".

    "Keep Trying"

  • Hi Johan, while Chirag has answered your question, just a short note about the names you are using. If you want your code to be portable, do not capitalize system view/table names (e.g. dbo.SysObject). These will not work on servers that are set up with case sensitive collations. The name should be dbo.sysobjects.

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply