SQL read number> 15 digit in Excel

bruindav

New Member
Joined
Dec 4, 2009
Messages
3
How can I retrieve a number > 15 digits from a database into Excel using a SQL query. Excel will cut off numbers at 15 position. So a Creditcard nr (16 digits) will lose it lasts digit
 

Some videos you may like

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
Welcome to the board..

In the database, store it as a TEXT instead of NUMBER.
 

bruindav

New Member
Joined
Dec 4, 2009
Messages
3
Thanks for the suggestion , but it is not possible to store it in de AS400 DB as text. I am not the owner of the database. I only have read permission. If you have any other suggestion you're welcome

Welcome to the board..

In the database, store it as a TEXT instead of NUMBER.
 

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
Perhaps formatting the destination cells as TEXT, PRIOR TO retrieving from the database?
 

bruindav

New Member
Joined
Dec 4, 2009
Messages
3
That's and option I have to try. :). Or maybe first store the result in a textvariable and than cut in two. :rolleyes:

Perhaps formatting the destination cells as TEXT, PRIOR TO retrieving from the database?
 

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
If that doesn't work, I would try concatenating the telephone number field to a character to convert to text (do this in the SQL itself). You'd need to process it after import if you wanted to remove the character.

I'm not sure of the driver (ODBC or OLEDB) that you're using so the following may not work:

Code:
SELECT 'A' + [TelNoField] FROM Table

etc etc. If you can, I would go for a concatenation using the sigle quote ' character as it will hopefully be placed into the cells as a textual number requiring no further modification.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,491
Messages
5,596,477
Members
414,070
Latest member
DuncanLucas

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top