Advertisement
Guest User

Untitled

a guest
Dec 16th, 2015
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. EmailAddress EntityId
  2.  
  3. 12_abc@abc.com::::13_pqr@pqr.com 101
  4. 12_koi@koi.com::::13_poi@poi.com 102
  5.  
  6. EmailAddress EmailTypeId EntityId
  7.  
  8. abc@abc.com 12 101
  9. pqr@pqr.com 13 101
  10. koi@koi.com 12 102
  11. poi@poi.com 13 102
  12.  
  13. DECLARE @MyTableVariable TABLE
  14. (
  15.  
  16. EmailAddress nvarchar(250),
  17. EntityIDE int
  18. );
  19.  
  20. INSERT @MyTableVariable(
  21. EmailAddress,
  22. EntityIDE
  23. )
  24.  
  25. SELECT concat([EmailTypeID], '_____', [EmailAddress]))), [EntityID]
  26. FROM [dbo].[Email_Addresses] where [EntityID] in
  27.  
  28. (select [EntityID] from [Entities] where [SourcePrimaryKey] in
  29. (select [MerchantOwnerID] from [dbo].[Merchant_Owners] where [MerchantID] = 1 ) and
  30. [EntityTypeID] = (select [EntityTypeID] from [Entity_Types] where [EntityType] = 'MerchantOwner'))
  31.  
  32. select * from @MyTableVariable
  33.  
  34. (select [EntityID] from [Entities] where [SourcePrimaryKey] in
  35. (select [MerchantOwnerID] from [dbo].[Merchant_Owners] where [MerchantID] = 1 ) and
  36. [EntityTypeID] = (select [EntityTypeID] from [Entity_Types] where [EntityType] = 'MerchantOwner'))
  37.  
  38. EntityId
  39.  
  40. 101
  41. 102
  42. 103
  43. 104
  44. ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement