Solved

REPLACE Query

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
LTrim & Double Space Correction 5 40
Row insertion failed. Array 5 46
First Max value 3 27
Reformat SQL - so SSRS can read the columns 25 11
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

840 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