Guest User

Untitled

a guest
Oct 16th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. create table #emails (personId int, email nvarchar(100), type char(1) )
  2.  
  3. insert into #emails values (1, 'bob@company.com', 't');
  4. insert into #emails values (1, 'bob@hotmail.com', 'h');
  5. insert into #emails values (2, 'bill@hotmail.com', 't');
  6. insert into #emails values (2, 'bill@gmail.com', 'h');
  7.  
  8. select * from #emails
  9.  
  10. drop table #emails
  11.  
  12. where (email like '%@company.com' and type = 'h') or
  13. (email not like '%@company.com' and type = 't')
  14.  
  15. create table #emails (personId int, email nvarchar(100), type as case when email like '%@company.com' then 'h' else 't' end)
Add Comment
Please, Sign In to add comment