I had a query like:
SELECT ISNULL(S.Name+'.'+T.Name,'Table Not Found')
FROM DataProfile.Tables T
INNER JOIN DataProfile.Schemas S ON T.schemaId=S.Id
WHERE S.Name+'.'+T.Name=@TableName
Then I tried
IIF(LEN(S.Name+'.'+T.Name)>0,S.Name+'.'+T.Name,NULL)
But when it doesn't find the named table returns not output, Value or Null value or anything I can work on.
This is going to be used as a crosscheck.
Does anybody have any idea?
Thanks for those who payed attention to what I exactly asked and for their responses. Here the way I tried:
DECLARE @Check NVARCHAR(MAX) = 'TABLE DOES NOT FOUND'
SELECT @Check= S.Name + '.' + T.Name
FROM DataProfile.Tables T
INNER JOIN DataProfile.Schemas S ON T.schemaId=S.Id
WHERE S.Name+'.'+T.Name=@TableName
SELECT @CHECK
And That Worked for me
this will always return a row:
select v.TableName, ISNULL(found.result, 'not found') result
from (values(@TableName))v(TableName)
outer apply (
select CAST('found' as nvarchar(11)) result
from DataProfile.Tables T
join DataProfile.Schemas S ON T.schemaId=S.Id
where S.Name+'.'+T.Name=v.TableName
)found
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