473,320 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Trying to update certain rows and its not producing the results i need

I am trying to update the titles of all the employees who ase listed as Sales Representative to say Sales Partners but when I execute this code it says no rows are effected and their titles are staying the same. Can someone help me figure out what I am doing wrong?

This is what I have.

USE Northwind
UPDATE dbo.Employees
SET Title = 'Sales Partners'
WHERE Title = 'Sales Representatives'

SELECT * FROM dbo.Employees
Dec 9 '09 #1
1 1468
nbiswas
149 100+
Your query is unquestionable(full correct) but I suspect that whether the exact record is matching or not(I don't have Northwind DB with me).

However, I have prepared a sample data with a query for you. Have a look and that might help you.

Sample data

Expand|Select|Wrap|Line Numbers
  1. declare @t table(empid int identity, empname varchar(10),title varchar(50))
  2. insert into @t 
  3.     select 'name1','Sales Representatives' union all
  4.     select 'name2', 'Sales             Representatives' union all
  5.     select 'name3', 'SalesRepresentatives' union all
  6.     select 'name4', '   Sales Representatives' union all
  7.     select 'name5' , 'some other title'
Query

Expand|Select|Wrap|Line Numbers
  1. UPDATE @t
  2. SET Title = 'Sales Partners'
  3. WHERE REPLACE(title,' ','') like '%'+ Replace('Sales Representatives',' ','') + '%'
  4. select * from @t
Output:

Expand|Select|Wrap|Line Numbers
  1. empid    empname    title
  2. 1    name1    Sales Partners
  3. 2    name2    Sales Partners
  4. 3    name3    Sales Partners
  5. 4    name4    Sales Partners
  6. 5    name5    some other title
As you can see, I have taken 4 variations for "Sales Representatives" and using like to find the match. Just check the same in the Northwind as how the data is stored over there!

Hope this helps
Dec 10 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Reply via newsgroup | last post by:
Folks, When performing an update in mysql (using PHP), can I find out how many records were matched? mysql_affected_rows() won't work... and I have the following problem that I thought I...
3
by: Mohammed Mazid | last post by:
Can anyone please help me here? Basically I have modified the source code and understood it but when I update a record in the db using a JSP, it gives me an error "The flight you selected does...
7
by: Dave | last post by:
I have 2 tables, one with names, and another with addresses, joined by their CIVICID number (unique to the ADDRESSINFO table) in Oracle. I need to update a field in the NAMEINFO table for a...
0
by: Jim C Nguyen | last post by:
I have a table with ~2.2 million rows. Sometimes when I do an update to one single row it will instead update ALL of the rows using the same update. This happens every one in about 500,000...
17
by: Felix | last post by:
Dear Sql Server experts: First off, I am no sql server expert :) A few months ago I put a database into a production environment. Recently, It was brought to my attention that a particular...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
0
by: M. David Johnson | last post by:
I cannot get my OleDbDataAdapter to update my database table from my local dataset table. The Knowledge Base doesn't seem to help - see item 10 below. I have a Microsoft Access 2000 database...
0
by: cmrhema | last post by:
Hello, I am having a problem with GRIDVIEW IN C#. The following code updates only the alternate rows. When i use the edit button all the cells does get converted to textboxes thereafter when i...
22
by: DreamersDelight | last post by:
Hi, I'm stuck on this problem and I can't find a sollution. I'm going to try and explain this step by step. 1 After certain rows get updated with a certain value. I don't know wich rows in...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.