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
 Adding More text to Column Row

Author  Topic 

kevin24
Starting Member

13 Posts

Posted - 2011-12-27 : 00:27:50
Hi, I have a database with many lines of data I wish to change the
data in one of the columns by adding additional text.

Currently the column shows 'FilePath' and the data shows 'xyz.jpg'.

I want the data to show 'Folder\xyz.jpg' where "Folder\" is the additional text to be added to each column row.

How do I achieve this please. Many thanks.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-12-27 : 00:35:19
[code]
update yourtable
set thecolumn = 'Folder\' + thecolumn
[/code]


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

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-27 : 02:27:36
[code]
update yourtable
set thecolumn = STUFF(thecolumn,1,0,'Folder\')
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

kevin24
Starting Member

13 Posts

Posted - 2011-12-27 : 03:54:33
Hi, Thanks very much.

I have one more update, which I guess is very much similar to the previous one.

The same database and table. I wish to change the
data in one of the columns by adding additional text.

Currently the column shows 'FilePath' and the data now shows 'Images\xyz.jpg or bmp'.

I want the data to show 'Images\xyz.jpg' ie. all show "a jpg file".

So the difference is that some data is being replaced.
Some of the data is already correct.

Many thanks your kind assistance again.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-12-27 : 04:05:57
[code]
update yourtable
set FilePath = replace(FilePath, '.bmp', '.jpg')
where FilePath like %.bmp%'
[/code]


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

Go to Top of Page
   

- Advertisement -