is it possible to select EXISTS directly as a bit?

后端 未结 9 1149
轻奢々
轻奢々 2020-12-02 09:09

I was wondering if it\'s possible to do something like this (which doesn\'t work):

select cast( (exists(select * from theTable where theColumn like \'theValue

9条回答
  •  情歌与酒
    2020-12-02 09:26

    Another solution is to use ISNULL in tandem with SELECT TOP 1 1:

    SELECT ISNULL((SELECT TOP 1 1 FROM theTable where theColumn like 'theValue%'), 0)
    

提交回复
热议问题