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
 Fast help Please

Author  Topic 

Zoma
Yak Posting Veteran

76 Posts

Posted - 2010-02-04 : 09:08:00
One of my developers asked me to update a culumn.
The table name is Bullet_Item and the culumn name is Desc_DBSource.

The Data in it is "DataSource=server02" in all rows like 400 of them.

I want to change "DataSource=server02" to "SQL2005" in all rows!

I hve tried this statement
select table name
update "DataSource=server02" = "sql2005"
go

but somehow it dsnt work. I just wana change the field DataSource=server02 to sql 2005

Please help

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-02-04 : 09:12:37
[code]
update t
set Desc_DBSource = 'sql2005'
from Bullet_Item t
where Desc_DBSource = 'DataSource=server02'
[/code]

or maybe you want to replace part of the string ?

[code]
update t
set Desc_DBSource = replace(Desc_DBSource, 'DataSource=server02','sql2005')
from Bullet_Item t
where Desc_DBSource like '%DataSource=server02%'
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-02-04 : 09:12:48
UPDATE Bullet_Item SET Desc_DBSource = 'sql2005'

At your own risk though...and you should probably look at www.w3schools.com/sql when you have some spare time. This is as basic as it gets.

- Lumbago
If the facts don't fit the theory, change the facts. Albert Einstein
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-04 : 09:13:46
[code]update Bullet_Item set Desc_DBSource ='SQL2005' where Desc_DBSource='DataSource=server02'[/code]
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-04 : 09:14:11
Go to Top of Page

Zoma
Yak Posting Veteran

76 Posts

Posted - 2010-02-05 : 01:28:57
Thanks a lot guys. It really helped. Now i can put more trust :). Life savers!
Go to Top of Page
   

- Advertisement -