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 2005 Forums
 Transact-SQL (2005)
 Need ur help about value

Author  Topic 

ejoeyz_85
Yak Posting Veteran

54 Posts

Posted - 2008-01-07 : 06:27:18
hello everybody... i have a problem with data type values in sql server 2005... the problem is when i keyed in value for handphone column something like 0123456789..then after that the first number 0 is missing... it juz showed 123456789...so how can i maintain the 0 for that value... plzzz help me.. what should i do??

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-01-07 : 06:30:51
Why do you want to maintain 0? If its just for the purpose of formatting like showing 0 prefixed value in the report or application screen, you should handle it there and not at the database side.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

ejoeyz_85
Yak Posting Veteran

54 Posts

Posted - 2008-01-07 : 06:40:10
actually my country for handphone number starting wif 0, so its important to keep 0 for the first value... so i choose int for data type... i know varchar or char is suitable coz its show for string and number.... but i choosed int n then the 0 is not showing... so how?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-01-07 : 06:50:11
you should user varchar for phone no.

You should change the data type to varchar() from int.

Create the new column and convert from old and append the '0' in front

update t
set new_col = '0' + convert(varchar(20), old_col)
from yourtable t



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -