• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

Update Column prefixes each value

Hi Guys

I have a simple issue and I can't work it out.

I need to write a Microsoft SQL script.

I have a table called Notes.
It includes 2 colums ID AND Note

I would like to go through each note prefixes the note with zz_

Any help highly appreciated

0
Shezad Ahmed
Asked:
Shezad Ahmed
1 Solution
 
Aneesh RetnakaranDatabase AdministratorCommented:
are u looking to update all the notes

UPDATE Notes
SET Note = 'zz_' + Note

0
 
TextReportCommented:
You can do this in your select

SELECT ID, 'zz_' + Note AS Note
FROM Notes

You may want to include the WHERE if Note can be NULL, please note (no pun intended) that if Note is Null it will return a Null when you do 'zz_' + Note

UPDATE Notes
SET Note = 'zz_' + Note
WHERE Note IS NOT NULL

Cheers, Andrew
0
 
LowfatspreadCommented:
sql server database?  (which version ?)

what is the datatype of the notes column?

update Notes
 set Note = 'zz_' + note
 Where substring(Note,1,3) <> 'zz_'


 
0
 
Shezad AhmedAuthor Commented:
Thanks.
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now