I'm looking for an alternative to using the command Exists
in procedures that I need to perform a large query and check if it returns some data, if it does not return to look for it should return a select with all its columns with the value '...'
.
How am I doing at the moment:
IF EXISTS(SELECT ..... FROM ..... WHERE .....) --Consulta muito grande, por isso não escrive ela.
BEGIN
SELECT ..... FROM ..... WHERE .....
END
ELSE
BEGIN
SELECT '...' as 'Col1', ....
END
The problem with this approach is that I need to run the query twice, causing a certain slowness in the procedure.