2011-06-02 181 views
5

我有一个SQL查询,我正在获取一些记录。 查询:如何从sql查询结果中删除空行?

select c.Id, c.FirstName, dbo.GetClientStaffContacts(c.Id, '27,31') as Staff from Client c order by c.Id 

结果是: enter image description here

我想只有那些没有在列的工作人员空值的行。

任何帮助,将不胜感激。 谢谢。

+2

你不得不重复UDF,即...其中dbo.GetClientStaffContacts(c.Id,'27,31' )IS NOT NULL – StuartLC 2011-06-02 07:30:58

+0

写条件语句一样,如果(!(Staff.Equals(NULL )){Query} – Naresh 2011-06-02 07:32:51

+0

@nonnb:非常感谢..它解决了我的问题:) – asma 2011-06-02 07:37:04

回答

12
select 
    c.Id, c.FirstName, dbo.GetClientStaffContacts(c.Id, '27,31') as Staff 
from 
    Client c 
where 
    dbo.GetClientStaffContacts(c.Id, '27,31') is not null 
order 
    by c.Id 
+0

谢谢Heximal,它解决了我的问题:) – asma 2011-06-02 07:39:00

+0

正确的答案,但有点贵,因为我有多个连接.. – Mukus 2014-04-23 01:29:55