IF OBJECT_ID_UDF('DATABASE2.DBO.TABLE1') is not null) THENDROPTABLEIFEXISTS TABLE1;ENDIF;
OUT -> SqlServer_01.sql
BEGIN-- ** SSC-EWI-0001 - UNRECOGNIZED TOKEN ON LINE 1 COLUMN 0 OF THE SOURCE CODE STARTING AT 'IF'. EXPECTED 'If Statement' GRAMMAR. **--IF OBJECT_ID_UDF('DATABASE2.DBO.TABLE1') is not null) THEN--** SSC-FDM-0007 - MISSING DEPENDENT OBJECT "TABLE1" **DROPTABLEIFEXISTS TABLE1;END;
2. Unknown database
Code:
IF OBJECT_ID_UDF('DATABASE1.DBO.TABLE1') is not null) THENDROPTABLEIFEXISTS TABLE1;ENDIF;
Code:
IF ( OBJECT_ID_UDF('DATABASE1.DBO.TABLE1') is not null) THENDROPTABLEIFEXISTS TABLE1;ENDIF;
3. Different object names
Code:
IF OBJECT_ID_UDF('DATABASE1.DBO.TABLE2') is not null) THENDROPTABLEIFEXISTS TABLE1;ENDIF;
Code:
IF ( OBJECT_ID_UDF('DATABASE1.DBO.TABLE2') is not null) THENDROPTABLEIFEXISTS TABLE1;ENDIF;
Known issues
1. OBJECT_ID_UDF function has different behavior in certain cases
OBJECT_ID returns the object identification number but the OBJECT_ID_UDF returns a boolean value, so that they are equivalent only when OBJECT_ID is used with not null condition.