Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. CREATE TABLE #three
  2. (
  3. colA varchar(32),
  4. colB varchar(32)
  5. );
  6.  
  7. INSERT #three(colA, colB) VALUES
  8. ('abc', 'xyz'),
  9. ('def', NULL),
  10. (NULL, 'ghi'),
  11. (NULL, NULL);
  12.  
  13. SELECT ColA, ColB,
  14. ColC = LTRIM(COALESCE(colA, '') + COALESCE(' '+colB,''))
  15. FROM #three;
  16.  
  17. DROP TABLE #three;
  18.  
  19. ColA ColB ColC
  20. ---- ---- -------
  21. abc xyz abc xyz
  22. def NULL def
  23. NULL ghi ghi
  24. NULL NULL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement