i have a field in a table that contains an account number. our numbers are 9 digits. (ex. 999-999-999) after exporting them into access from one of our programs they show without the hyphen (ex. 999999999) i was wondering if there is any way, like a query or something that i can use to add the missing hyphens. they will always be after the 3rd and 6th digits. any ideas? thanks!
Try this, -
Left(AccNum,3) & '-' & Mid(AccNum,4,3) & '-' & Right([AccNum,3) AS AccountNumber
-
But I would use this for display purposes only, it is always best to store this as a number in the table.
-AJ
7 1830
Try this, -
Left(AccNum,3) & '-' & Mid(AccNum,4,3) & '-' & Right([AccNum,3) AS AccountNumber
-
But I would use this for display purposes only, it is always best to store this as a number in the table.
-AJ
Why would you store a phone number as a number rather than text?
If I remember correctly, it has something to do with numbers store better than text, and is easier to index. I could be wrong but that is what I have based what I've done on.
I would assume they will be doing searches on the Account Number.
-AJ
Sorry, just noticed that it was an account number and not a phone number. Regardless, I think it is a mistake to use a number field to hold something you can't use math on. What if the account number is 000000001?
Great point! That did not occur to me, didacticone, I believe ChipR makes a good point, you should make the appropriate changes.
But I think the rule still applies to phone number, I will have to research this more, but I know I heard a pro and con discussion about this before and number storing was the way to go.
Thanks for keeping me honest ChipR. =)
-AJ
As long as you don't need country codes, extensions, etc. :)
NeoPa 32,556
Expert Mod 16PB
Just to add my two pennies worth here :
I can only think of calculations as a reason for storing formatted numbers as numbers rather than as strings. I'd be interested in seeing where anyone contests otherwise. It would be good to read what they had to say ... before I told them how wrong they were!! :D
Actually, because of the inherent problems with numbers no matter how they're held, I would always advise not using any value that can be ambiguous for identification fields. Account numbers as "02151" for instance is a recipe for bucket loads of confusion down the line. Even if you have a few level-headed IT people who can handle it you are absolutely guaranteed to find people in the organisation for whom a number stored as text is a thought too far. Trust me when I say this will eventually come back to you, no matter how well you handle the data yourself.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: traceable1 |
last post by:
I am inserting data rows into a table via a stored procedure. After
the inserts, I query the rows in the table and I want them to spit
back out in the same order I put them in.
However,...
|
by: me |
last post by:
I'm also having problems getting the bulk insert to work. I don't know
anything about it except what I've gleened from BOL but I'm not seeming to
get anywhere...Hopefully there is some little (or...
|
by: akej via SQLMonster.com |
last post by:
Hi, i have table with 15 columns
CREATE TABLE . (
PRIMARY KEY ,
NULL ,
NULL ,
NULL ,
NULL ,
(50) NULL ,
NULL
|
by: Christian Soltenborn |
last post by:
Hi experts,
I am working on a university project based on VB .NET. I have a
connection to MS Access, and I want to insert some data into the
database. The sql command
INSERT INTO Shoe (Brand,...
|
by: ben.werdmuller |
last post by:
Hi,
Is there an easy way in ASP/VBscript to grab an autonumber (primary
key) field just after an SQL insert? This is probably easy, but I'm
stuck ..
Cheers.
|
by: Carl |
last post by:
Hi,
I hope someone can share some of their professional advice and help me out
with my embarissing problem concerning an Access INSERT query. I have never
attempted to create a table with...
|
by: Chris Fink |
last post by:
I have setup an Oracle table which contains a blob field. How do I insert
data into this field using C# and ADO.net?
|
by: MP |
last post by:
Hi
Posted this several hours ago to another ng but it never showed up thought
i'd try here.
using vb6, ado, .mdb, jet4.0, no access
given table tblJob with field JobNumber text(10)
'The...
|
by: Lyn |
last post by:
Hi,
Is there an "easy" way to write a full record (all fields) using "INSERT
INTO..." into a table which has an AutoNumber field?
Normally, to write a full new record I would use:
INSERT INTO...
|
by: chumlyumly |
last post by:
Hello scripters -
OS: Mac OSX
Language: PHP w/ MySQL database
I've created an insert page where a user inputs his info, which then goes to four different tables in a MySQL database. The...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |