0

I have table in which I have hotel names but some columns have Null hotel names. Now I want to get only those columns having hotel names or I don't want to get null column values from table.

My stored procedure that I wrote is

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

   SELECT
       Hotel_Info.Hotel_Name, Hotel_Info.HotelID 
   FROM 
       Hotel_Info

END
2
  • 1
    What are you really trying to do? have you tried just selecting count(Hotel_Name)? This will not count nulls. Commented Jun 7, 2013 at 12:55
  • I think you shouldn't have hotel names as null in the first place. It would be better to sort out it in the function where you inserting/updating the records. And then make Hotel_Name field Not null. Commented Jun 7, 2013 at 13:00

1 Answer 1

3

You should try this

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.