mssql check if the output from select returns empty or null Edit

Murugan Andezuthu Dharmaratnam | 15 October 2020 | 104

How do i check if the output from a select statement is null or empty?. In script I had to create a temporary table if the output from select is empty, This is how I did it.

SQL Script

IF NOT EXISTS(select * from #SetupCuisineId)
  insert into #SetupCuisineId select SetupCuisineId as Id from Recipe


The syntax for EXISTS is. EXISTS ( subquery ) subquery Is a restricted SELECT statement. The INTO keyword is not allowed. the return value is a boolean, Returns TRUE if a subquery contains any rows.