| Author |
Topic |
|
aakcse
Aged Yak Warrior
570 Posts |
Posted - 2010-06-14 : 12:28:22
|
| I was trying to convert the below oracle code to sqlserver 2005select TO_CHAR(OPTION_PRICE, '9999.999999') from table...select convert(varchar,OPTION_PRICE) from table...so far it looks good, giving correct results, but I am bit worried it may fail? could anyone provide some information on it plz.-Neil |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-06-14 : 12:34:06
|
varchar without length (i.e. varchar(25) or so) is dangerous because there is a default length (I don't know maybe 10).See also here for more info:http://msdn.microsoft.com/de-de/library/ms187928.aspx No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2010-06-14 : 13:38:05
|
| Use the STR() function to format numbers in SQL Server:SELECT STR(OPTION_PRICE, 10, 6) FROM table |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-06-14 : 13:46:24
|
the VARCHAR default is 30 characters. N 56°04'39.26"E 12°55'05.63" |
 |
|
|
aakcse
Aged Yak Warrior
570 Posts |
Posted - 2010-06-14 : 13:56:10
|
| Thanks All,well I know the Char default is 1Brett, I have a code(few application proc) written in oracle, which I need to convert to sqlserver hmm facing lot of problemI'll try using STR if any problem arise in testing the code later on, once again thanks all.Thanks.-Neil |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
aakcse
Aged Yak Warrior
570 Posts |
Posted - 2010-06-15 : 02:31:31
|
| Brett,We need to convert it because Oracle is Client system and we doing analysis in SQL and we do not have Oracle at our end, as like wise there are over 100dbs to be migrated from different systems to SQL(migrated succesfully), however when it comes to Oracle it is bit difficult.-Neil |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-06-15 : 02:34:19
|
quote: Originally posted by robvolk Use the STR() function to format numbers in SQL Server:SELECT STR(OPTION_PRICE, 10, 6) FROM table
Only if there is no front end application to do it MadhivananFailing to plan is Planning to fail |
 |
|
|
aakcse
Aged Yak Warrior
570 Posts |
Posted - 2010-06-15 : 02:46:20
|
| hmm what could be the problem with varchar with out length-Neil |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-06-15 : 02:53:24
|
quote: Originally posted by aakcse hmm what could be the problem with varchar with out length-Neil
Did you read my first reply?MadhivananFailing to plan is Planning to fail |
 |
|
|
aakcse
Aged Yak Warrior
570 Posts |
Posted - 2010-06-15 : 05:47:19
|
| Yes Maddy I read all of your reply-Neil |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-06-15 : 05:49:54
|
quote: Originally posted by aakcse hmm what could be the problem with varchar with out length-Neil
So what you are asking?Do you have a problem or do you want to know if problems could occur? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
aakcse
Aged Yak Warrior
570 Posts |
Posted - 2010-06-15 : 07:31:11
|
| Thanks Allwas trying to know if problems could occurThanks again-Neil |
 |
|
|
|