473,387 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

insert into field

266 256MB
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!
Sep 16 '09 #1

✓ answered by ajalwaysus

Try this,

Expand|Select|Wrap|Line Numbers
  1. Left(AccNum,3) & '-' &  Mid(AccNum,4,3) & '-' & Right([AccNum,3) AS AccountNumber
  2.  
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
ajalwaysus
266 Expert 100+
Try this,

Expand|Select|Wrap|Line Numbers
  1. Left(AccNum,3) & '-' &  Mid(AccNum,4,3) & '-' & Right([AccNum,3) AS AccountNumber
  2.  
But I would use this for display purposes only, it is always best to store this as a number in the table.

-AJ
Sep 16 '09 #2
ChipR
1,287 Expert 1GB
Why would you store a phone number as a number rather than text?
Sep 16 '09 #3
ajalwaysus
266 Expert 100+
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
Sep 16 '09 #4
ChipR
1,287 Expert 1GB
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?
Sep 16 '09 #5
ajalwaysus
266 Expert 100+
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
Sep 16 '09 #6
ChipR
1,287 Expert 1GB
As long as you don't need country codes, extensions, etc. :)
Sep 16 '09 #7
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.
Sep 16 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
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,...
5
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...
20
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
1
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,...
3
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.
8
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...
11
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?
3
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...
4
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...
0
chumlyumly
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...
0
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,...
0
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$) { } ...
0
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...
0
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...
1
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...
0
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.