Posts

Showing posts from May, 2015

Code to fetch GROUPED delimiter separated records in SQL SERVER

Image
/* To return GROUPED delimiter separated records in OUTER QUERY which are already delimiter separated in INNER QUERY (SQL SERVER 2012) */ /* Table for Merchant Registration */ DECLARE @mer_registration TABLE ( mer_id INT ) INSERT INTO @mer_registration(mer_id) VALUES (1111111), (1212121) --SELECT * FROM @mer_registration /* Table for Merchant Sub Account  */ DECLARE @sub_account TABLE ( mer_id INT, sub_mer_id VARCHAR(50) ) INSERT INTO @sub_account(mer_id, sub_mer_id) VALUES (1111111,'sub_121'), (1111111,'sub_122'), (1111111,'sub_123'), (1111111,'sub_124'), (1111111,'sub_125'), (1111111,'sub_126'), (1111111,'sub_127'), (1212121,'sub_123'), (1212121,'sub_124') --SELECT * FROM @sub_account /* Table for merchant Report  */ DECLARE @account_report TABLE ( mer_id INT, sub_mer_id VARCHAR(50), report_type VARCHAR(10) ) INSERT INTO @account_