-- زیر مقداری را برگرداند، باید تاریخ صدور و سررسید Query در صورتی که
--           با شرط زیر اصلاح شود CheckGetPayDetail تمام رکوردهای جدول

Select 
	* 
from 
	ATNDBTest.dbo.CheckGetPayDetail 
where 
	len(IssueDate) < 10 or 
	len(MatureDate) < 10 or
	substring(IssueDate,5,1) <> '/' or
	substring(IssueDate,8,1) <> '/' or
	substring(MatureDate,5,1) <> '/' or
	substring(MatureDate,8,1) <> '/' or
	Len(Cast((replace(IssueDate,'/','')) as bigint)) <> 8 or
	Len(Cast((replace(MatureDate,'/','')) as bigint)) <> 8 





Select 
	* 
from 
	ATNDBTest.dbo.FactorHeader 
where 
	len(EffectiveDate) < 10 or 
	len(PayDate) < 10 or
	substring(EffectiveDate,5,1) <> '/' or
	substring(EffectiveDate,8,1) <> '/' or
	substring(PayDate,5,1) <> '/' or
	substring(PayDate,8,1) <> '/' or
	Len(Cast((replace(EffectiveDate,'/','')) as bigint)) <> 8 or
	Len(Cast((replace(PayDate,'/','')) as bigint)) <> 8 



--Update ATNDBTest.dbo.FactorHeader 
--Set PayDate = EffectiveDate
--where 
--	len(EffectiveDate) < 10 or 
--	len(PayDate) < 10 or
--	substring(EffectiveDate,5,1) <> '/' or
--	substring(EffectiveDate,8,1) <> '/' or
--	substring(PayDate,5,1) <> '/' or
--	substring(PayDate,8,1) <> '/' or
--	Len(Cast((replace(EffectiveDate,'/','')) as bigint)) <> 8 or
--	Len(Cast((replace(PayDate,'/','')) as bigint)) <> 8 
