tsql - Conditionals in transact-sql select column lists -


I have found a query that looks a bit like this:

  records Select ID, Contacts. Name + '(' + contact 'organization' + ') As a contact, join on the records from Records. Record. Contact = contact Contact  

The problem is - contact. Organization is often empty, and I get contacts like "John Smith ()" Is this just a way to incorporate the organization if it is not empty?

Use a CASE statement

  SELECT records.id, CASE contacts. The organization, when contacted in the name of "contact names, contact names as ELSE contacts.name + '(' + contact.organization + ')' END Records, on the Spaces Records .contact = contacts.contactid  

You can modify it to check tap values, but I believe that you do not have this problem because if you did not have a number in your contacts, Your entire result field is empty instead of the free space


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -