By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,843 Members | 2,324 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,843 IT Pros & Developers. It's quick & easy.

how to update set some added string

P: 83
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
Share this Question
Share on Google+
5 Replies


ck9663
Expert 2.5K+
P: 2,878
what's the data type of kod_pusat_kos ?


-- CK
Nov 11 '08 #2

P: 83
kod_pusat_kos char(10)
Nov 11 '08 #3

amitpatel66
Expert 100+
P: 2,367
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
Expert 2.5K+
P: 2,878
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

P: 83
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.