/*AUTHOR: Amrita Vishnoi
PURPOSE: Extending Licenses for Institution: EMC Publishing LLC po E10007276
DATE: 11-Sep-2017 */

update LicenseSubscriptionDetail set SubscriptionValidFrom='2017-09-11 00:00:00.000' , SubscriptionValidThrough='2019-09-11 23:59:59.997'
where LicenseId in (
(SELECT Id from License where InstitutionName = 'WKLabGuide1replacement') )


update License set IsActive=1 
where id in (
SELECT LicenseId FROM LicenseSubscriptionDetail
WHERE LicenseId in
(SELECT Id from License where InstitutionName = 'WKLabGuide1replacement') 
and (SubscriptionValidFrom='2017-09-11 00:00:00.000' and SubscriptionValidThrough='2019-09-11 23:59:59.997'))

****************************** If SubscriptionValidFrom and  SubscriptionValidThrough old dates are available then run below query**********

update LicenseSubscriptionDetail
set SubscriptionValidFrom = '2016-10-19 00:00:00.000', SubscriptionValidThrough = '2017-10-18 23:59:59.997'
WHERE LicenseId in
(SELECT Id from License where InstitutionName = 'EMC Publishing LLC po E10007276') 
and (SubscriptionValidFrom='2013-01-08 00:00:00.000' and SubscriptionValidThrough='2014-01-07 23:59:59.997')

update License set IsActive=1 
where id in (
SELECT LicenseId FROM LicenseSubscriptionDetail
WHERE LicenseId in
(SELECT Id from License where InstitutionName = 'EMC Publishing LLC po E10007276') 
and (SubscriptionValidFrom='2016-10-19 00:00:00.000' and SubscriptionValidThrough='2017-10-19 23:59:59.997'))