2011-06-02 179 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