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 |
satish15385
Starting Member
17 Posts |
Posted - 2011-11-10 : 13:48:10
|
I am trying to import data from excel to SQl Server.I have a column with values "00.12", "00.01" etc...Format.In Sql Server that column is varchar. how can i replace the decimals here and make the output column as 0012,0001,1302,1500 format |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-11-10 : 13:49:44
|
update tblset col = replace(replace(col,'.',''),'"')==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2011-11-10 : 13:50:10
|
Using the replace funciton?DECLARE @Foo DECIMAL(14,3) = 987654.123;SELECT REPLACE(CAST(@Foo AS VARCHAR(15)), '.', '') |
 |
|
satish15385
Starting Member
17 Posts |
Posted - 2011-11-10 : 13:53:24
|
Thank for the Quick response,I am writting a SSIS Package and so after extracting from excel source, the column values in sql are showing up as follows:11.011.090000001.100000001.110000001.120000001111.0111.071313.0113.029999913.039999913.0913.113.109999913.1199999please let me know wat i need to do to get the same format from excel to SQL |
 |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-11-10 : 13:54:58
|
Easiest to just run the update after the import. Otherwise it's a datatype conversion and maybe expression in the dataflow.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
|
satish15385
Starting Member
17 Posts |
Posted - 2011-11-10 : 15:13:30
|
Problem i am facing is that...I cannot export excel row "01.00" as same in SQl...its showing as only 1 |
 |
|
|
|
|
|
|