August 27, 2013 at 9:28 pm
I have two tables setup where one contains a list of keywords and category The second table contains actual data description. By mapping the keywords on the Data description column, we will have to update the respective category.
Can we achieve the same using a Query or we have to write a Procedure?
August 28, 2013 at 6:27 am
Please provide sample tables, data, and expected output. We can't do much for you without that as a starting point. Also, I don't understand your question about query or procedure...
Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service
August 28, 2013 at 7:08 am
Hi,
I am here by attaching a sample excel workbook where we have two worksheets, one represents the first table and second worksheet represents the issues table which needs to be updated on the category column based on the Keywords available in the Keywords table.
As this is a sample, we have few rows.. in reality there are more than a lakh of rows in the Issues table.
My query was with regards to a SQL query with which we can update the categories on the Issues table based on the Keywords table.
Thanks,
Ram240582
August 28, 2013 at 1:01 pm
I don't open excel spreadsheets from the web.
Sorry, I wasn't specific enough in my request. I (and others that might help you) need CREATE TABLE scripts (temporary tables please, not permanent ones) and INSERT ... scripts that we can run directly on SQL Server to use to build a query that can help solve your problem. We need your expected outputs from the given inputs so we can really understand what you mean/need.
Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service
August 28, 2013 at 3:30 pm
If this is a one-off you could do:
UPDATE issues
SET category = (SELECT MIN (k.category)
FROM keywords k
WHERE i.description LIKE '%' + k.keyword + '%')
FROM keywords k
I will be really slow.
If you need to do this on a regular basis, you need to consider full-text indexing.
[font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]
August 28, 2013 at 5:20 pm
Ram240582 (8/27/2013)
I have two tables setup where one contains a list of keywords and category The second table contains actual data description. By mapping the keywords on the Data description column, we will have to update the respective category.Can we achieve the same using a Query or we have to write a Procedure?
Welcome aboard. To get better and quicker answers in the future, most likely with a coded example that actually works, please see the first link in my signature line below.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply