Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Removing Extraneous data

Author  Topic 

CBee
Starting Member

15 Posts

Posted - 2010-11-30 : 11:29:07
I have a database with the following table:
column:link (varchar (max), null)
Data in link is as follows:
www.garbagecollectors-serious-law-firm.com">The garbagecollectors<
skinnerdems.com">Skinner Dems<
www.Military-Veterans-garbagecollectors.org">Military Vets & garbagecollectors<

What I would like to do is remove everything after the " so I am left with the following:
www.garbagecollectors-serious-law-firm.com
skinnerdems.com
www.Military-Veterans-garbagecollectors.org

As can be seen, not all links end the same, nor do all links have www in them.
I tried to figure out how to use parsename and replace but was unsuccessful in my attempts.
any suggestions?
Charlie

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2010-11-30 : 11:34:20
something like

update tbl
set link = left(link,len(link) - charindex('"',reverse(link)))
where link like '%"%'


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

CBee
Starting Member

15 Posts

Posted - 2010-11-30 : 11:41:31
That worked great. Thanks,
Charlie
Go to Top of Page
   

- Advertisement -