Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

update rank of tag if word in mentioned in the caption

Posted on 2014-01-29
6
Medium Priority
?
286 Views
Last Modified: 2014-01-29
Dear all,
Need to update NewsSYSNewsTags.RankInCaption= 5
where NewsSYSTags.TagTitle IN STRING of News.NewsCaptionAR
and
News.NewsID=1011 and  NewsSYSNewsTags.NewsID=1011 and
NewsSYSNewsTags.NewsSYSTagsID  = NewsSYSTags.NewsSYSTagsID

thanks
0
Comment
Question by:ethar1
  • 4
6 Comments
 

Author Comment

by:ethar1
ID: 39817747
I have 3 tables
News : NewsID , NewsCaptionAR
NewsSYSTags : where I store unique tags (NewsSYSTagsID (pk) , TagTitle  )
NewsSYSNewsTags : where I store (NewsSYSNewsTagsID =pk) , NewsID , NewsSYSTagsID (fk)
0
 
LVL 12

Accepted Solution

by:
Harish Varghese earned 1800 total points
ID: 39817803
Try this:
update NewsSYSNewsTags
Set NewsSYSNewsTags.RankInCaption = 5 
From NewsSYSNewsTags, NewsSYSTags, News
where NewsSYSNewsTags.NewsSYSTagsID  = NewsSYSTags.NewsSYSTagsID
and News.NewsID = NewsSYSNewsTags.NewsID
and IndexOf(rtrim(NewsSYSTags.TagTitle), News.NewsCaptionAR) > 0 -- Tag appears in Caption
and News.NewsID = 1011 --Look for specific news

Open in new window

-Harish
0
 
LVL 60

Assisted Solution

by:Kevin Cross
Kevin Cross earned 200 total points
ID: 39817929
Harish, I think you meant CHARINDEX versus INDEXOF above.
CHARINDEX: http://technet.microsoft.com/en-us/library/ms186323.aspx

Note: you may get a few false positives if your tag is a common part of other words.  For example, suppose your tag is "bask" then it will match to "basket" and "basketball."  As another aside, if you enabled full-text search on SQL Server, you may be able to use those functions to assist you here.

Anyway, I just wanted to assist with the correct T-SQL function to find index of character/string as INDEXOF is not valid for Microsoft SQL Server.  You need CHARINDEX, PATINDEX, or full-text search like CONTAINS.

Full-text: http://technet.microsoft.com/en-us/library/ms142571.aspx

I hope that helps!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Closing Comment

by:ethar1
ID: 39818070
thanks guys
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question