CREATE PROCEDURE usp_PoliticalProcessing
AS
UPDATE dbo.list_staging
SET sPhone = RTrim(LTrim(Convert(varchar(30), Convert(numeric(20, 1), phone))))
UPDATE dbo.list_staging
SET sPhone = Substring(sphone, 1, patindex('%.%', sphone)-1)
UPDATE dbo.list_staging
SET sphone = replace(replace(replace(replace(replace(replace(sphone,'.',''),',','' ),'-',''), ' ',''), '(', ''), ')', '')
ALTER TABLE dbo.list_staging ADD [iList_StagingID] INT IDENTITY(1,1)
ALTER TABLE dbo.list_staging ADD [sFailedValidation] char(1)
Update dbo.list_staging
SET sFailedValidation = 'X'
WHERE(Len(RTrim(LTrim(sPhone))) <> 10)
UPDATE a
SET a.sFailedValidation = 'X'
FROM dbo.list_staging a
INNER JOIN dbo.list_staging b
ON a.sPhone= b.sPhone
WHERE(a.iList_StagingID > b.iList_StagingID)