2

Its been quite a while since I've run an SQL query and I need a bit of help.

I have a SQL Server database in which I need to do a string find/replace on text content in column "content" in table named "my_table". I'm getting an "invalid object name" error when I try to execute the SQL:

UPDATE dbo.MY_TABLE
  SET CONTENT = REPLACE(CONTENT, 'http://123.123.123.123', 'http://www.mysite.com')
  WHERE CONTENT LIKE '%http://123.123.123.123%';

The website's html content is stored inside the "my_table" table in a field labeled "Content". I have thousands of instances of the IP address which need to be updated to reflect the new domain name.

3
  • I'm connected to the database and looking at the table, inserted the SQL above into the query field and clicked "Execute", then I get the error in the bottom window of SQL Manager Commented Jan 30, 2013 at 21:14
  • Did you try my suggestion -- running: SELECT * FROM dbo.My_Table? Commented Jan 30, 2013 at 21:16
  • Apparently I was in the wrong database. The query works. Thanks! Commented Jan 30, 2013 at 21:20

3 Answers 3

3

Seems to work fine for me:

http://sqlfiddle.com/#!3/451de/1

My guess is that the owner of My_Table isn't dbo? Can you:

SELECT * FROM dbo.My_Table

Good luck.

Sign up to request clarification or add additional context in comments.

Comments

-1
UPDATE dbo.MY_TABLE
SET CONTENT = example.com --Enter your actual website name
WHERE CONTENT LIKE oldexample.com --enter what address you want replace

Comments

-1

The problem is the field name. It is a reserved word. Change content by [content]

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.