468,242 Members | 1,546 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,242 developers. It's quick & easy.

how to update set some added string

i have tblPeribadi as table of database
i want to add some string to each row for column kod_pusat_kos
maybe like this..
Expand|Select|Wrap|Line Numbers
  1. UPDATE tblPeribadi SET Kod_Pusat_Kos='00'+Kod_Pusat_Kos WHERE Kod_Pusat_Kos>10000001
Nov 11 '08 #1
5 2197
ck9663
2,878 Expert 2GB
what's the data type of kod_pusat_kos ?


-- CK
Nov 11 '08 #2
kod_pusat_kos char(10)
Nov 11 '08 #3
amitpatel66
2,367 Expert 2GB
Yes you can concatenate the data to the existing value of the column but that should not exceed 10 Characters
Nov 11 '08 #4
ck9663
2,878 Expert 2GB
If you're considering of left-padding your column with zeros, consider this:


Expand|Select|Wrap|Line Numbers
  1.  
  2. UPDATE tblPeribadi 
  3. SET Kod_Pusat_Kos=right('0000000000'+Kod_Pusat_Kos,10)
  4. WHERE cast(Kod_Pusat_Kos as int) >10000001
  5.  
  6.  
Happy coding!

-- CK
Nov 11 '08 #5
If you're considering of left-padding your column with zeros, consider this:


Expand|Select|Wrap|Line Numbers
  1.  
  2. UPDATE tblPeribadi 
  3. SET Kod_Pusat_Kos=right('0000000000'+Kod_Pusat_Kos,10)
  4. WHERE cast(Kod_Pusat_Kos as int) >10000001
  5.  
  6.  
Happy coding!

-- CK
Thanks CK and i did it with LEFT
Nov 17 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by sdash | last post: by
5 posts views Thread by explode | last post: by
4 posts views Thread by tim.cavins | last post: by
reply views Thread by tdes42 | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.