Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default question about the data type in excel


Hi, I encounter a problem when doing some data transition work from excel to
sql server, there is a column in the excel sheet in which most contents are
integer but still some are words, after the transition I found in the
coresponding table of sql that the rows whose value is not integer in excel
are set as null, seems the excel treat the column as int type so the words
are omitted, I tried to change the class of cell into "text" the column's
property the still the same thing happens. I tried both DTS in sqlserver and
write c# code through OleDb to do this job and got the same result. I just
want get the values as varchars with non-integer ones reserved. What should I
do ?

p.s in some test I tried I found that if a column contains mostly alphabet
words and few integers , the integers will be set as null after the
transitions, so looks like the excel will give the column a type according to
the type of its most rows. All I want to to get all the values as varchars,
please helpl, thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default question about the data type in excel

I can't tell if the problem is occuring in excel or when the data is stored
on the SQL server.

Try these two things.

1) Declare a variable as a string in excel and store the data into the
string variable in excel before storing the data in the SQL server.

2) Put the string in single quotes before saving on the SQL Server

Dim MyString as String

MyString = range("A1")
MyString = chr(39) & MyString & chr(39)


"fairyvoice" wrote:


Hi, I encounter a problem when doing some data transition work from excel to
sql server, there is a column in the excel sheet in which most contents are
integer but still some are words, after the transition I found in the
coresponding table of sql that the rows whose value is not integer in excel
are set as null, seems the excel treat the column as int type so the words
are omitted, I tried to change the class of cell into "text" the column's
property the still the same thing happens. I tried both DTS in sqlserver and
write c# code through OleDb to do this job and got the same result. I just
want get the values as varchars with non-integer ones reserved. What should I
do ?

p.s in some test I tried I found that if a column contains mostly alphabet
words and few integers , the integers will be set as null after the
transitions, so looks like the excel will give the column a type according to
the type of its most rows. All I want to to get all the values as varchars,
please helpl, thanks

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 - Lookup type of question Fran Excel Worksheet Functions 3 June 4th 09 12:30 AM
Type A Question MGP31 New Users to Excel 4 February 6th 07 12:36 PM
Type a Question for Help MGP31 Excel Discussion (Misc queries) 2 February 4th 07 09:44 AM
how get rid of "Type a question for help" box Ian Elliott Excel Discussion (Misc queries) 2 September 28th 05 06:01 PM
Sum if type question? Dan Excel Worksheet Functions 3 May 28th 05 04:34 AM


All times are GMT +1. The time now is 01:00 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"