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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 An update script please

Author  Topic 

sqllearner
Aged Yak Warrior

639 Posts

Posted - 2004-06-04 : 18:51:22
tabel1

emp_ids
--------
2423423
4547667
7878
787687

I want this emp_ids to be a 12 digit varchar by adding 0's to the beginning of the number if its not a 10 digit number...
Please I need a script very urgent

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-06-04 : 18:57:12
Is this a homework question?


So you want it to be 12 digits if it isn't 10 in length already or did you mean to type 12 ("if its not a 10 digit number")?


Tara
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2004-06-04 : 19:00:19
Yeah this screams of homework.
Well, I'll point you in the right direction. Do some research on REPLICATE. I think with some actual work, you can make that do what you want. If you have the Books Online there's a sample on how to do this.

Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2004-06-04 : 19:52:52
do you need to update an existing table and change the values, or do you need to select from a table and transform the data in the select?


-ec
Go to Top of Page

sqllearner
Aged Yak Warrior

639 Posts

Posted - 2004-06-04 : 20:42:26
I figured it out..but thanks a lot for the help...
update table1
set emp_ids=right(replicate('0',10) + (emp_ids), 10)


Go to Top of Page
   

- Advertisement -