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.
| Author |
Topic |
|
bjbrennan
Starting Member
2 Posts |
Posted - 2006-06-09 : 21:59:08
|
| Ok What I am looking to do is add http:// to all fields in a table that do not already begin with http://. The query I have come up with so far is the following. However it does not work and I am hopeing that somone that knows what they are doing can give a new guy a hand please.UPDATE CompanySET Company.URL = 'http://' + CompanyURLWHERE Company.CompanyURLIN(SELECT Company.CompanyURLFROM CompanyGROUP BY Company.CompanyURLHAVING (((NOT LEFT(Company.CompanyURL,7) = 'http://')))) |
|
|
bjbrennan
Starting Member
2 Posts |
Posted - 2006-06-09 : 22:04:44
|
| Sorry I spazed after fussing with this for 15 mins already. The answer was verry simple and one of those duhhhh errors.UPDATE CompanySET Company.CompanyURL = 'http://' + CompanyURLWHERE Company.CompanyURLIN(SELECT Company.CompanyURLFROM CompanyGROUP BY Company.CompanyURLHAVING (((NOT LEFT(Company.CompanyURL,7) = 'http://')))) |
 |
|
|
DustinMichaels
Constraint Violating Yak Guru
464 Posts |
Posted - 2006-06-09 : 22:43:43
|
Why are you using a group by and sub select in your update statement? You could rewrite it asUPDATE aSET a.CompanyURL = 'http://' + a.CompanyURLFROM Company aWHERE a.CompanyURL NOT LIKE 'http://%' |
 |
|
|
|
|
|