The following query results only "Operation is Success" whilst my aim is to run the "Select" statement listed under IF TRUE condition:
DECLARE @TOTAL int
Select @TOTAL = count(barcode)
from domain_Media
where ( (librarySlotNumber > -1)
AND (UPPER(volumePoolName) LIKE UPPER('scratch%'))
AND (id LIKE '05%' or id LIKE 'DX%')
AND (masterServerId = 17785613) )
IF (@TOTAL > 5)
BEGIN
select *
from domain_Media
where (masterServerId = 17785613)
END
Where am I going wrong?
Why not just use a single query?
select *
from domain_Media
where masterServerId = 17785613 and
(select count(barcode)
from domain_Media
where librarySlotNumber > -1 and
upper(volumePoolName) like upper('scratch%') and
(id like '05%' or id like 'DX%') and
masterServerId = 17785613
) > 5;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With