Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7713479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:53:10+00:00 2026-06-01T01:53:10+00:00

I need to test if a string (filenames with their complete path) contains another

  • 0

I need to test if a string (filenames with their complete path) contains another one in MSSQL.

My script needs to check if the file we are about to commit is present in the database under a specific column (pre-hook script).

I cannot really change the data definition of the column, but we are currently using text TEXT and files are seperated by a new line character. I tried to use TSQL function CONTAINS, but the overall performance is not really good.

Would it be a better idea to load all the data in a PHP array and do the comparaison locally ?

I’m not quite sure what is best way to do here.

Update: There is about 194 530 rows in the database.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:53:11+00:00Added an answer on June 1, 2026 at 1:53 am

    The main thing to keep in mind when doing a search through a string is that you want to limit the length of the string you are searching through. Right now, you have multiple path+filename values tucked into a single row-column pair – as I’ve mentioned above, this is poorly normalized (and is part of the reason you’re having trouble doing lookups).

    Given that you can’t really change the schema of the table you’re having trouble with, a better alternative might be creating a structure to work with the metadata that describes the files stored within a certain row.

    For example, one option might be to create a table that contains filename–rowID pairs, where each row of the original table is linked to the parsed-out filenames within the TEXTcolumn of that row. That gives you the option of limiting your search by first doing a lookup on a shorter string (the filename), and then using that constraint to help search a smaller number of rows to satisfy the path+filename combination and achieve a unique result.

    If you have a large number of files with identical names, another option might be to implement a hash index, using rowIDs from your original table and a hash of each path+filename from that row using CHECKSUM() or whatever hashing function you have available.

    Using an ‘indexing’ table like this one does add overhead: you have to maintain the metadata as the original table gets updated, but it also means you’re doing your heavy lifting ahead of time and making future queries of the data much faster.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For a JUnit test I need a String which consists of multiple lines. But
I need to test if a file is a shortcut. I'm still trying to
I need to test a function that needs to query a page on an
I need to test a web form that takes a file upload. The filesize
I have a pdf on one server I need to pass on another server.
I need to test whether various types of database objects exist in a given
I need to test a serial port application on Linux, however, my test machine
I need to test a site with a dynamic menu in Mac Firefox, but
I need to test a JDBC connection to a database. The java code to
I need to test a url that it does not end with .asp So

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.