1. 程式人生 > >SQL判斷查詢結果是否存在EXISTS

SQL判斷查詢結果是否存在EXISTS

IF NOT EXISTS (SELECT 0 FROM [train_enroll_data] WHERE [courseId] = 636235546473141211)
        BEGIN
            SELECT CAST(1 AS BIT)
        END
ELSE
        BEGIN
            SELECT CAST(0 AS BIT)
        END