Hello I am trying to create a query that would loop through a table in my sql server, but the problem is I need to filter the query by a certain portion of one of the columns of the table. For example the fields of the table (and an example value) are shown below(table name on top and value directly below):
PDID PDDescription PDFilename PDDocumentLocation PDDocumentTypeID
77234 PDF for FRT FRT_154327 PD Documents\154487 11
The problem is I need to filter by number section of the PDDocumentlocation, like I would have a set of PD numbers and those numbers correlate with the "PD Documents\####" this section -> ###, is there any way to create a loop query that would pull out these values based on a portion of a column? Also if possible can I reference a folder location in SQL? and for PDDocumentLocation it will always begin with PD Documents if that helps. Thank you! I tried googling iterating through tables but I cant find anything on iterating based on a parameter like a list of numbers and that referring a art of a column. Any help is greatly appreciated.
For example if I have a list of PD Numbers like 12456,13788, 23456 then I want the query to return all the rows that have those numbers and those numbers come from the column "PDDocumentLocation" and all the values in that column start out with 'PD Documents\' and the number list corresponds as such: PD Documents\12456, PD Documents\13788, PD Documents\23456