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 |
|
miked1978
Starting Member
25 Posts |
Posted - 2008-09-19 : 08:48:38
|
| I have a column called "Acct" which should have 4 digit numbers in them. However there are several numbers who only have 3 digits. Luckily I know those records all need to have a zero in the front.For example I have 50 records with 713 in the Acct field. They need to be 0713. I know I can do a simple update statement to fix that particular one but I also have several records with 701, 850, 940 accts so I need a update statement that will set any 3 digit acct to 4 digits by inserting a zero at the beginning.Please help. Thanks for your help. |
|
|
ayamas
Aged Yak Warrior
552 Posts |
Posted - 2008-09-19 : 08:57:57
|
| declare @num intset @num=701select right('0000'+ convert(varchar(4),@num) ,4)o/p will be 0701But if the value of @num is 7100 o/p will be 7100 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-19 : 09:34:23
|
| Whats the datatype of Acct field? |
 |
|
|
|
|
|