Home Forums SQL Server 2008 SQL Server Newbies How can I count the number of occurances of a string in an ntext column for each record? RE: How can I count the number of occurances of a string in an ntext column for each record?

  • Mixolydian (10/1/2012)


    Wow! I had hoped to find a response but I am overwhelmed. Thank you all very much!

    Lowell, thank you for the valuable tip. I do need to check for <table in case there are some classes or other values in the opening tag.

    SSCommitted, You are quite right, this database has been around a while. Thank you for the suggestion I will read up on changing the data type.

    And ChrisM@Work & laurie-789651, thank you both for your code! Both your examples are way over my head, but I'm going to pick them apart and learn how they work.

    I've already run the query (with the <table modification) and found the 500 or so records out of 30,000 which need fixing. I'm very happy! :w00t:

    Thank you all again! πŸ˜€

    You're welcome, thanks for the feedback. If you have trouble understanding the solutions posted, just ask πŸ˜‰

    β€œWrite the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden