I have a select statement and I want to say if this select statement does not return any rows then put a '' in every cell. How do I do this?
select a, b, c from t
if @@rowcount = 0
select '' as a, '' as b, '' as c
But make sure you understand that ''
may have a different datatype than columns a
, b
, and c
.
Try this -
IF NOT EXISTS ( SELECT 'x' FROM <TABLE> .... )
BEGIN
-- Your logic goes here
END
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