Guest User

Untitled

a guest
Dec 16th, 2015
138
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.  
  4. EmailAddress EmailTypeId EntityId
  5.  
  6.  
  7. DECLARE @MyTableVariable TABLE
  8. (
  9.  
  10. EmailAddress nvarchar(250),
  11. EntityIDE int
  12. );
  13.  
  14. INSERT @MyTableVariable(
  15. EmailAddress,
  16. EntityIDE
  17. )
  18.  
  19. SELECT concat([EmailTypeID], '_____', [EmailAddress]))), [EntityID]
  20. FROM [dbo].[Email_Addresses] where [EntityID] in
  21.  
  22. (select [EntityID] from [Entities] where [SourcePrimaryKey] in
  23. (select [MerchantOwnerID] from [dbo].[Merchant_Owners] where [MerchantID] = 1 ) and
  24. [EntityTypeID] = (select [EntityTypeID] from [Entity_Types] where [EntityType] = 'MerchantOwner'))
  25.  
  26. select * from @MyTableVariable
  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. EntityId
  33.  
  34. 101
  35. 102
  36. 103
  37. 104
  38. ...
Advertisement
Add Comment
Please, Sign In to add comment