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
 General SQL Server Forums
 New to SQL Server Programming
 Number stored as text in excel file

Author  Topic 

ruchijani
Starting Member

23 Posts

Posted - 2009-07-07 : 01:00:07
Hello

I have used OPENROWSET to export sql server table data to excel file like


DECLARE @STR VARCHAR(1000)

SET @STR = 'INSERT INTO OPENROWSET(''' + @provider + ''',''' + @ExcelString + ''',''SELECT col1,col2,col3 FROM [Sheet1$]'')
SELECT col1,col2,col3 FROM table1'

EXEC(@STR)

it works fine but problem is that col1 and col2 are of decimal type in table and converted to text in excel file so i could not apply any formula to that column and little green tags which represent 'number stored as text' not seen in excel file


So is there any way to solve problem with the use of sql server so that number not stored as text in excel file

Please help me

Thanks
Ruchi

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-07-07 : 01:30:08
Try changing your IMEX mode.


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-07-07 : 01:52:43
or pre-format the execl cell to Number and export data to it

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

ruchijani
Starting Member

23 Posts

Posted - 2009-07-08 : 01:35:49
Hiiii

I tried with IMEX=0 and IMEX=1 but it does not work for me

So Is this only way to pre-format the excel cell ?


Thanks
Ruchi
Go to Top of Page
   

- Advertisement -