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.
| Author |
Topic |
|
philippe1024
Starting Member
1 Post |
Posted - 2006-05-29 : 10:46:23
|
| Hi everybody,Could someone help me ???Iam starting with sqlMy problem ..Ihave a table Table_customerIn this table a column Table_customer.noThis column contain 8000 rows.with customer numbers: like 30789I would like to modify once all this row adding just before the numbera value to all these rows.This value will be a 60So will have instaed of 30789 a 6030789 This column is an integer.I have try a simple select wich give me this resultHow i can do this with update ?probably i have to convert fisrt to caractersselect kunr,nov_kunr='30'+ltrim(str(kunr))from eventwhere kunr is not nullThank |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2006-05-29 : 11:08:10
|
update table_cutomerSet id = 6000000 + idwhere some conditionGo with the flow & have fun! Else fight the flow Blog thingie: [URL="http://weblogs.sqlteam.com/mladenp"] |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-05-29 : 12:27:13
|
| philippe1024,Do u want to add the 2 characters '6' & '0' in front or add a 6000000 to the customer numbersBoth will givethe same results as ling as customer numbers < 99999if u want to precede with 2 characters '60' in front of any customer #u may need to convert the customer # to varchar & concatenate that with '60'eg.Set @custNum = '60' + convert(varchar(20), '30789' )or Set id = '60' + convert(varchar(20), id)if u want to update the table with that value, u may need to convert it back to int (may be for a larger value the int size may be insufficient, so that u may need to go for bigintSrinika |
 |
|
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
|
|
|
|
|