Stored Procedure SQL 2005

Posted on 2011-04-20
Last Modified: 2012-05-11
I have a stored procedure where I display the following column InsuredFile.LastName in a datasheet. What I want is if SlotType <> S then display InsuredFile.LastName if SlotType = S then display nothing for InsuredFile.LastName
Question by:mburk1968
    LVL 19

    Accepted Solution


    you can use

    SELECT CASE WHEN SlotType<>5 then  InsuredFile.LastName else '' end as LastName
    FROM TableName

    LVL 21

    Expert Comment

    by:Alpesh Patel
    Select (Case When SlotType <> 'S' then InsuredFile.LastName Else NULL END) From Table

    Expert Comment

    SELECT CASE WHEN SlotType<>5
                  THEN InsuredFile.LastName END as LastName
    FROM TableName

    => if SlotType=5 the value for LastName will be NULL!

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
    Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now