select 'DY2022' as DBNAME, bill_no,bill_type, count(*) as CT from dy2022.dbo.bill group by bill_no, bill_type having COUNT(*) >1 union
select 'DY2021' as DBNAME, bill_no,bill_type, count(*) as CT from DY2021.dbo.bill group by bill_no, bill_type having COUNT(*) >1 union
select 'DY2020' as DBNAME, bill_no,bill_type, count(*) as CT from dy2020.dbo.bill group by bill_no, bill_type having COUNT(*) >1 union
select 'DY2019' as DBNAME, bill_no,bill_type, count(*) as CT from DY2019.dbo.bill group by bill_no, bill_type having COUNT(*) >1 union
select 'DY2018' as DBNAME, bill_no,bill_type, count(*) as CT from DY2018.dbo.bill group by bill_no, bill_type having COUNT(*) >1 union
select 'DY2017' as DBNAME, bill_no,bill_type, count(*) as CT from DY2017.dbo.bill group by bill_no, bill_type having COUNT(*) >1 union
select 'DY2016' as DBNAME, bill_no,bill_type, count(*) as CT from DY2016.dbo.bill group by bill_no, bill_type having COUNT(*) >1 union
select 'DY2015' as DBNAME, bill_no,bill_type, count(*) as CT from DY2015.dbo.bill group by bill_no, bill_type having COUNT(*) >1 union
select 'DY2014' as DBNAME, bill_no,bill_type, count(*) as CT from DY2014.dbo.bill group by bill_no, bill_type having COUNT(*) >1 union
select 'DY2013' as DBNAME, bill_no,bill_type, count(*) as CT from DY2013.dbo.bill group by bill_no, bill_type having COUNT(*) >1 union
select 'DY2012' as DBNAME, bill_no,bill_type, count(*) as CT from DY2012.dbo.bill group by bill_no, bill_type having COUNT(*) >1

select 'DY2022' as DBNAME, propertykey, count(*) as CT from dy2022.dbo.property group by propertykey having COUNT(*) >1 union 
select 'DY2021' as DBNAME, propertykey, count(*) as CT from DY2021.dbo.property group by propertykey having COUNT(*) >1 union 
select 'DY2020' as DBNAME, propertykey, count(*) as CT from dy2020.dbo.property group by propertykey having COUNT(*) >1 union 
select 'DY2019' as DBNAME, propertykey, count(*) as CT from DY2019.dbo.property group by propertykey having COUNT(*) >1 union 
select 'DY2018' as DBNAME, propertykey, count(*) as CT from DY2018.dbo.property group by propertykey having COUNT(*) >1 union 
select 'DY2017' as DBNAME, propertykey, count(*) as CT from DY2017.dbo.property group by propertykey having COUNT(*) >1 union 
select 'DY2016' as DBNAME, propertykey, count(*) as CT from DY2016.dbo.property group by propertykey having COUNT(*) >1 union 
select 'DY2015' as DBNAME, propertykey, count(*) as CT from DY2015.dbo.property group by propertykey having COUNT(*) >1 union 
select 'DY2014' as DBNAME, propertykey, count(*) as CT from DY2014.dbo.property group by propertykey having COUNT(*) >1 union 
select 'DY2013' as DBNAME, propertykey, count(*) as CT from DY2013.dbo.property group by propertykey having COUNT(*) >1 union 
select 'DY2012' as DBNAME, propertykey, count(*) as CT from DY2012.dbo.property group by propertykey having COUNT(*) >1

select 'DY2022' as DBNAME, realkey, count(*) as CT from dy2022.dbo.property where proptype = 'r' group by realkey having COUNT(*) >1 union 
select 'DY2021' as DBNAME, realkey, count(*) as CT from DY2021.dbo.property where proptype = 'r' group by realkey having COUNT(*) >1 union 
select 'DY2020' as DBNAME, realkey, count(*) as CT from dy2020.dbo.property where proptype = 'r' group by realkey having COUNT(*) >1 union 
select 'DY2019' as DBNAME, realkey, count(*) as CT from DY2019.dbo.property where proptype = 'r' group by realkey having COUNT(*) >1 union 
select 'DY2018' as DBNAME, realkey, count(*) as CT from DY2018.dbo.property where proptype = 'r' group by realkey having COUNT(*) >1 union 
select 'DY2017' as DBNAME, realkey, count(*) as CT from DY2017.dbo.property where proptype = 'r' group by realkey having COUNT(*) >1 union 
select 'DY2016' as DBNAME, realkey, count(*) as CT from DY2016.dbo.property where proptype = 'r' group by realkey having COUNT(*) >1 union 
select 'DY2015' as DBNAME, realkey, count(*) as CT from DY2015.dbo.property where proptype = 'r' group by realkey having COUNT(*) >1 union 
select 'DY2014' as DBNAME, realkey, count(*) as CT from DY2014.dbo.property where proptype = 'r' group by realkey having COUNT(*) >1 union 
select 'DY2013' as DBNAME, realkey, count(*) as CT from DY2013.dbo.property where proptype = 'r' group by realkey having COUNT(*) >1 union 
select 'DY2012' as DBNAME, realkey, count(*) as CT from DY2012.dbo.property where proptype = 'r' group by realkey having COUNT(*) >1

select 'DY2022' as DBNAME, perskey, count(*) as CT from dy2022.dbo.property where proptype = 'p' group by perskey having COUNT(*) >1 union 
select 'DY2021' as DBNAME, perskey, count(*) as CT from DY2021.dbo.property where proptype = 'p' group by perskey having COUNT(*) >1 union 
select 'DY2020' as DBNAME, perskey, count(*) as CT from dy2020.dbo.property where proptype = 'p' group by perskey having COUNT(*) >1 union 
select 'DY2019' as DBNAME, perskey, count(*) as CT from DY2019.dbo.property where proptype = 'p' group by perskey having COUNT(*) >1 union 
select 'DY2018' as DBNAME, perskey, count(*) as CT from DY2018.dbo.property where proptype = 'p' group by perskey having COUNT(*) >1 union 
select 'DY2017' as DBNAME, perskey, count(*) as CT from DY2017.dbo.property where proptype = 'p' group by perskey having COUNT(*) >1 union 
select 'DY2016' as DBNAME, perskey, count(*) as CT from DY2016.dbo.property where proptype = 'p' group by perskey having COUNT(*) >1 union 
select 'DY2015' as DBNAME, perskey, count(*) as CT from DY2015.dbo.property where proptype = 'p' group by perskey having COUNT(*) >1 union 
select 'DY2014' as DBNAME, perskey, count(*) as CT from DY2014.dbo.property where proptype = 'p' group by perskey having COUNT(*) >1 union 
select 'DY2013' as DBNAME, perskey, count(*) as CT from DY2013.dbo.property where proptype = 'p' group by perskey having COUNT(*) >1 union 
select 'DY2012' as DBNAME, perskey, count(*) as CT from DY2012.dbo.property where proptype = 'p' group by perskey having COUNT(*) >1

select 'DY2022' as DBNAME, mobilekey, count(*) as CT from dy2022.dbo.property where proptype = 'm' group by mobilekey having COUNT(*) >1
select 'DY2021' as DBNAME, mobilekey, count(*) as CT from DY2021.dbo.property where proptype = 'm' group by mobilekey having COUNT(*) >1
select 'DY2020' as DBNAME, mobilekey, count(*) as CT from dy2020.dbo.property where proptype = 'm' group by mobilekey having COUNT(*) >1
select 'DY2019' as DBNAME, mobilekey, count(*) as CT from DY2019.dbo.property where proptype = 'm' group by mobilekey having COUNT(*) >1
select 'DY2018' as DBNAME, mobilekey, count(*) as CT from DY2018.dbo.property where proptype = 'm' group by mobilekey having COUNT(*) >1
select 'DY2017' as DBNAME, mobilekey, count(*) as CT from DY2017.dbo.property where proptype = 'm' group by mobilekey having COUNT(*) >1
select 'DY2016' as DBNAME, mobilekey, count(*) as CT from DY2016.dbo.property where proptype = 'm' group by mobilekey having COUNT(*) >1
select 'DY2015' as DBNAME, mobilekey, count(*) as CT from DY2015.dbo.property where proptype = 'm' group by mobilekey having COUNT(*) >1
select 'DY2014' as DBNAME, mobilekey, count(*) as CT from DY2014.dbo.property where proptype = 'm' group by mobilekey having COUNT(*) >1
select 'DY2013' as DBNAME, mobilekey, count(*) as CT from DY2013.dbo.property where proptype = 'm' group by mobilekey having COUNT(*) >1
select 'DY2012' as DBNAME, mobilekey, count(*) as CT from DY2012.dbo.property where proptype = 'm' group by mobilekey having COUNT(*) >1

select 'DY2022' as DBNAME, parcel_no, proptype, count(*) as CT from dy2022.dbo.property where proptype = 'r' group by parcel_no, proptype having COUNT(*) >1 union
select 'DY2021' as DBNAME, parcel_no, proptype, count(*) as CT from DY2021.dbo.property where proptype = 'r' group by parcel_no, proptype having COUNT(*) >1 union
select 'DY2020' as DBNAME, parcel_no, proptype, count(*) as CT from dy2020.dbo.property where proptype = 'r' group by parcel_no, proptype having COUNT(*) >1 union
select 'DY2019' as DBNAME, parcel_no, proptype, count(*) as CT from DY2019.dbo.property where proptype = 'r' group by parcel_no, proptype having COUNT(*) >1 union
select 'DY2018' as DBNAME, parcel_no, proptype, count(*) as CT from DY2018.dbo.property where proptype = 'r' group by parcel_no, proptype having COUNT(*) >1 union
select 'DY2017' as DBNAME, parcel_no, proptype, count(*) as CT from DY2017.dbo.property where proptype = 'r' group by parcel_no, proptype having COUNT(*) >1 union
select 'DY2016' as DBNAME, parcel_no, proptype, count(*) as CT from DY2016.dbo.property where proptype = 'r' group by parcel_no, proptype having COUNT(*) >1 union
select 'DY2015' as DBNAME, parcel_no, proptype, count(*) as CT from DY2015.dbo.property where proptype = 'r' group by parcel_no, proptype having COUNT(*) >1 union
select 'DY2014' as DBNAME, parcel_no, proptype, count(*) as CT from DY2014.dbo.property where proptype = 'r' group by parcel_no, proptype having COUNT(*) >1 union
select 'DY2013' as DBNAME, parcel_no, proptype, count(*) as CT from DY2013.dbo.property where proptype = 'r' group by parcel_no, proptype having COUNT(*) >1 union
select 'DY2012' as DBNAME, parcel_no, proptype, count(*) as CT from DY2012.dbo.property where proptype = 'r' group by parcel_no, proptype having COUNT(*) >1

select 'DY2022' as DBNAME, parcel_no, count(*) as CT from dy2022.dbo.property where proptype = 'p' group by parcel_no having COUNT(*) >1
select 'DY2021' as DBNAME, parcel_no, count(*) as CT from DY2021.dbo.property where proptype = 'p' group by parcel_no having COUNT(*) >1
select 'DY2020' as DBNAME, parcel_no, count(*) as CT from dy2020.dbo.property where proptype = 'p' group by parcel_no having COUNT(*) >1
select 'DY2019' as DBNAME, parcel_no, count(*) as CT from DY2019.dbo.property where proptype = 'p' group by parcel_no having COUNT(*) >1
select 'DY2018' as DBNAME, parcel_no, count(*) as CT from DY2018.dbo.property where proptype = 'p' group by parcel_no having COUNT(*) >1
select 'DY2017' as DBNAME, parcel_no, count(*) as CT from DY2017.dbo.property where proptype = 'p' group by parcel_no having COUNT(*) >1
select 'DY2016' as DBNAME, parcel_no, count(*) as CT from DY2016.dbo.property where proptype = 'p' group by parcel_no having COUNT(*) >1
select 'DY2015' as DBNAME, parcel_no, count(*) as CT from DY2015.dbo.property where proptype = 'p' group by parcel_no having COUNT(*) >1
select 'DY2014' as DBNAME, parcel_no, count(*) as CT from DY2014.dbo.property where proptype = 'p' group by parcel_no having COUNT(*) >1
select 'DY2013' as DBNAME, parcel_no, count(*) as CT from DY2013.dbo.property where proptype = 'p' group by parcel_no having COUNT(*) >1
select 'DY2012' as DBNAME, parcel_no, count(*) as CT from DY2012.dbo.property where proptype = 'p' group by parcel_no having COUNT(*) >1


select * from vPROPERTY where PROPERTYKEY is null or PROPERTYKEY = ''

select * from vPROPERTY where PROPERTYKEY = 14893 and DIGYR = 2018

select * from bill where PROPERTYKEY = 33530

select * from vPROPERTY where PROPTYPE = 't' --and DIGYR = 2022
select * from vPROPERTY where PROPTYPE = 'h'

select * from dy2015.dbo.bill where isnull(BALANCE_DUE,0) < 0
select * from dy2015.dbo.bill where BALANCE_DUE is null

