Solved

REPLACE Query

Posted on 2011-09-21
2
185 Views
Last Modified: 2012-05-12
I have data in a field as follows, a couple of examples are

[dbo].[Jonh Bloggs]
[dbo].[The Results Home Page]

I am looking to remove [dbo].[] so I would ber left with

Jonh Bloggs
The Results Home Page

The database is SQL 2008
0
Comment
Question by:halifaxman
  • 2
2 Comments
 
LVL 25

Accepted Solution

by:
Lee Savidge earned 500 total points
ID: 36573037
update mytable set myfield = replace(replace(myfield, '[dbo].[', ''), ']', '')
0
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 36573061
Or:

update mytable set myfield = right(left(myfield, len(myfield) - 1), len(left(myfield, len(myfield) - 1)) - 7)

But the replace above is better :)
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

930 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now