Solved

REPLACE Query

Posted on 2011-09-21
2
184 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

762 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

19 Experts available now in Live!

Get 1:1 Help Now