CousinBrucie
Programmer
Hello,
I am writing a stored procedure to compare values within a File Name stored in one table to the stored values in another.
Here is an example of the filename:
TESTCOMPANY_ABCD_23_NEW_SUBMISSION.txt.
The filename along with a timestamp is stored in a table named SubmissionManagement. Then, the corresponding records for this file are inserted into another table called Submission which stores each record in the file. Then I need to compare parts of the filename in the SubmissionManagement table to corresponding records in the Submission table. For example, if the filename column in the SubmissionManagement table has the value 23 then the CompanyID field in corresponding records for the Submission table should have the value 23 for all records. If any records do not have this value, then I update the FileLoadStatus flag column in the SubmissionManagement table to 4 (Failed Validation). It would also be nice to return a record count of the failed records, but for now it can just be an all or nothing deal.
I have been searching for examples on this and have seen some brief examples using PATINDEX and SUBSTRING but nothing that actually parses out parts of a filename and compares those values to values in another table, which I assume would involve a loop of some kind. Any help would be greatly appreciated.
Thanks,
Bruce
I am writing a stored procedure to compare values within a File Name stored in one table to the stored values in another.
Here is an example of the filename:
TESTCOMPANY_ABCD_23_NEW_SUBMISSION.txt.
The filename along with a timestamp is stored in a table named SubmissionManagement. Then, the corresponding records for this file are inserted into another table called Submission which stores each record in the file. Then I need to compare parts of the filename in the SubmissionManagement table to corresponding records in the Submission table. For example, if the filename column in the SubmissionManagement table has the value 23 then the CompanyID field in corresponding records for the Submission table should have the value 23 for all records. If any records do not have this value, then I update the FileLoadStatus flag column in the SubmissionManagement table to 4 (Failed Validation). It would also be nice to return a record count of the failed records, but for now it can just be an all or nothing deal.
I have been searching for examples on this and have seen some brief examples using PATINDEX and SUBSTRING but nothing that actually parses out parts of a filename and compares those values to values in another table, which I assume would involve a loop of some kind. Any help would be greatly appreciated.
Thanks,
Bruce