SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Problem with EXCEL


Problem with EXCEL

Author
Message
sql2k8
sql2k8
SSC-Addicted
SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)

Group: General Forum Members
Points: 451 Visits: 1115
i had to load the data from sql server data base tables. i used store procedure to load the data .the stored procedure gives three columns when i run it
so my source is sql server
i had to create a table in excel and load the data into the three colums
i had to create an excel table with three colums.
CREATE TABLE `New Table` (
`column a` VarChar (9) ,
`column b` VarChar (8) ,
`column c` VarChar (254) )
when i do data conversions and when i load the data the first two columns are getting loaded properly.the third column is loading in this fashion '0123 i have to get 0123 only i am getting '0123 in my third column.
when i did my data conversions i had used each of these options( DT_WSTR , DT_NTEXT) .
when i use these options i get the above mentioned issue '0123 but not 0123.
please can any one help me with this

Thank You,
Dan.Humphries
Dan.Humphries
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1393 Visits: 1212
Is the leading zero required? If it is and you are using a template excel file and not a new file then set that field as text in your template file. If you are not using a template file you might want to.
As I understand it the first row is sampled in the result set and if a leading zero is found then it treats it like text and adds the single quote. If the leading zero is not required you can also cast or convert in the sql statement so that the number is treated correctly.

I have had this same problem and while I think the explanation is a little odd that SQL treats a leading zero in this way I do find that either of the two steps I mention have fixed it for me.

Dan

If only I could snap my figures and have all the correct indexes apear and the buffer clean and.... Start day dream here.
Koen Verbeeck
Koen Verbeeck
SSC-Dedicated
SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)

Group: General Forum Members
Points: 34237 Visits: 13270
sql2k8 (4/22/2010)

when i use these options i get the above mentioned issue '0123 but not 0123.


Putting '0123 in Excel is the same as 0123. The ' serves as a text identifier, so that Excel knows that it is text and not a number, otherwise it would drop the leading zero.


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
lbouaziz
lbouaziz
Grasshopper
Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)

Group: General Forum Members
Points: 10 Visits: 20
i'm agree with Da Zero (like always Smile )

but what u can try is to add a fake first line with a text in the third column.

another thing is that Excel format the data with the top ten (not sure about the number, maybe more, maybe less) rows of the dataset.

There is an option to change the number of line that are analyzed by excel.

this is a key is the reg db

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Excel\TypeGuessRows

hope it helps
sql2k8
sql2k8
SSC-Addicted
SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)

Group: General Forum Members
Points: 451 Visits: 1115
when i changed colum c data type to int in the template new table



and when i did the data conversion to 8 bit unsigned integer in my data flow task. i was able to eliminate the single quote problem.

thank you very much for your help
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search