存储过程不从表中检索空值

时间:2013-06-07 12:47:27

标签: sql-server stored-procedures

我有桌子,其中我有酒店名称,但有些栏目有Null酒店名称。现在我想只获得那些具有酒店名称的列,或者我不想从表中获取空列值。

我写的存储过程是

Alter PROCEDURE [dbo].[p_Get_HotelNamess]  
AS  
BEGIN  
   SET NOCOUNT ON;  

   SELECT
       Hotel_Info.Hotel_Name, Hotel_Info.HotelID 
   FROM 
       Hotel_Info

END

1 个答案:

答案 0 :(得分:3)

你应该试试这个

Alter PROCEDURE [dbo].[p_Get_HotelNamess]  

AS  
BEGIN  

 SET NOCOUNT ON;  

 SELECT 
     Hotel_Info.Hotel_Name, Hotel_Info.HotelID 
 FROM Hotel_Info 
 WHERE Hotel_Info.Hotel_Name IS NOT NULL

END