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 |
|
hydtohou
Starting Member
24 Posts |
Posted - 2007-11-09 : 13:12:42
|
| Hi This might be simple but I'm in a hurry so here is the question.I have something like this declare @col decimal(7,4)set @col = 123.45select @colit assigns it as 123.4500 which is fineBut, Can I take out the extra 00's ; because the Input that I get might have something like 1234.56; at this point Input is correct but when I load to SQL table it will fail because SQL Server adds 00'sand the precision would become 8 and failI don't know whether I can change the datatype to decimal(10,4) for example.Regards, |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2007-11-09 : 13:29:51
|
| Why not change it to (7,2) instead?[Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
hydtohou
Starting Member
24 Posts |
Posted - 2007-11-09 : 13:31:15
|
I'm not sure I can do that either. It's not in my hands.quote: Originally posted by DonAtWork Why not change it to (7,2) instead?
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-11-09 : 13:41:03
|
Not evenSELECT CAST(Col1 AS DECIMAL(7, 2))FROM Table1 E 12°55'05.25"N 56°04'39.16" |
 |
|
|
hydtohou
Starting Member
24 Posts |
Posted - 2007-11-09 : 13:49:53
|
I'm trying to insert not selectquote: Originally posted by Peso Not evenSELECT CAST(Col1 AS DECIMAL(7, 2))FROM Table1 E 12°55'05.25"N 56°04'39.16"
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-11-09 : 13:55:48
|
How on earth can some extra zeros fail an insert to a decimal field? E 12°55'05.25"N 56°04'39.16" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-11-09 : 13:56:27
|
INSERT NewTable (NewCol)SELECT CAST(OldCol AS DECIMAL(7, 2))FROM OldTable E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|
|
|