Store Phone Numbers/Zip Codes As Char(length) Or Numeric Datatypes?

Dec 18, 2003

I'm wondering which way is the best way to store your numeric values.


It probably doesnt matter, b/c you can always convert back and forth...but i'm just wondering what the best practice is i guess...








thx

View 1 Replies


ADVERTISEMENT

Formatting Phone Numbers

Jul 17, 2000

What is the simplest way to format the 10 digit numeric string that represents a phone number, so that the result appearing on a web page looks like (xxx) xxx-xxxx. Should this take place in the database or out at the web server or where?

View 1 Replies View Related

RE:PHONE NUMBERS UPDATE

Aug 14, 2001

I am trying to update a bunch of phone numbers in a sql 6.5 db.
The phone numbers are in the following formate.
(aaa)-xxx-cccc
I need to update xxx to yyy. Has anyone done this before.
Please help.


Thanks in advance

Ken

View 3 Replies View Related

Formatting Phone Numbers In SQL

May 28, 2008

Here's my problem: I have to clean up a SQL Server 2005 database with a large number of phone number records (several hundred thousand). The records are of varchar datatype and contain phone numbers in every format imaginable. In fact, many records have written notes regarding the phone numbers after the numbers themselves. What I need to do is format all of the phone numbers to this format:

###-###-####-

Basically I'm figuring I need to do the following:
1. Strip all non-numeric characters from the record
2. Remove the 1 from any records that have a leading 1 (in many cases the records contain stuff like 1-888-555-1234)
3. Remove any digits following the first 10 digits (they don't want to keep any extensions - the formatting is more important)
4. Add dashes after the first three digits, after the second three and at the end of the phone number

This seems like a rather complex problem to me, and honestly I don't even know where to begin. I can accomplish this rather easily in javascript or C#, but writing SQL to solve this is beyond me. I'd really appreciate any help you guys can provide. Thanks alot!

View 14 Replies View Related

Storing Phone Numbers

Jul 20, 2005

Hi,In SQL Server 2000, if I have to create a table to store a very largenumber of 10 digit telephone numbers, would I be better off to have abigint field or just use a varchar field? If I do a lot of queryingbased on the telephone numbers, would it be faster if I use bigint?Are there any other tricky points that I should know when using bigintfields? I need to be able to accesss this field from VB6 and VB.NET.Thanks,--TP

View 3 Replies View Related

Datatypes Nchar/nvarchar Vs Char/varchar

Dec 2, 2005

can anybody please explain me why microsoft using nvarchar/nchar instead of varchar/char in northwind database and pubs database. I know if a column holds unicode data you should use nvarchar or nchar but for me all those tables in northwind/pubs are not holding unicode data. but still why microsoft settled for nchar/nvarchar.

View 2 Replies View Related

Fixing Phone Numbers To Correct Format

Aug 14, 2014

I am trying to find all the records in our database that have the incorrect phone number format and fix them to the correct format.

CREATE TABLE MDR (
SiteName nvarchar(255),
BusinessEmailAddress nvarchar(255),
FirstName nvarchar(255),
LastName nvarchar(255),
JobTitle nvarchar(255),
PersonBusinessPhoneNumber nvarchar(255),
SiteBusinessPhoneNumber nvarchar(255))

[code]....

View 1 Replies View Related

Stripping Input Mask From Phone Numbers

Mar 28, 2006

Hello, I have this Access 2K query that I need to re-create in MS SQLServer 2000, so I'm using the Query Analyzer to test it.One of the Access fields stores the home phone number. In the Accessquery, if the phone number is null, it fills it up with zeroes"000000000." If the phone has an input mask, it only gets the 9 numbers(area code included) and if the phone number's good (all numbers) thenit leaves it alone. That Access query is using immediate ifs toaccomplish that task.Does anyone have any idea how to copy this behavior into SQL Server2000? I've using the CASE statement but so far my code is not correct.I get stuck in the input mask. This is the Access code:HomePhone:IIf(IsNull([HomePhone]),"0000000000",IIf(Left([HomePhone],1)="(",Right(Left([Homephone],4),3)& Right(Left([Homephone],9),3) & Right([HomePhone],4),[HomePhone]))Thanks for all your help.JR.

View 2 Replies View Related

CASE Function Home Phone Work Phone Cell Phone

May 8, 2008



Hi,

I'm trying to create a case function for home phone ,work phone and cell phone. The thing is some of the home phone numbers either null, zero or less than 10 digits then i'd like to get either cell phone or work phone if they are not null, zero or less than 10 digits.

I'd appreciate it if you could help me on this?

Thanks in advance.

View 19 Replies View Related

SQL Precision Arithmetic Overflow Error For Numeric And Decimal Datatypes

Jul 23, 2005

I've a SQL view performing a number of very precise calculations ie.495/(1.112 - (.00043499*((Col1 + Col2 + Col3))) + ( .00000055 * ((Col1+ Col2 + Col3)) * ((Col1 + Col2 + Col3))) - (.00028826 * Col4))) -450)/100Obviously this sometimes causes a precision issues because the floatand real datatypes don't hold precise values... My problem is thatconverting to the numeric or decimal datatype easily produces an errorif the precision is not big enough to hold the resulting output... Sohere's my questions:Does anyone see a problem with me maxing out the precision of thedecimal datatype (ie. use DECIMAL(38,8) across a couple dozeninter-related formulas?So the above code would now exec like this:495/(CONVERT(DECIMAL(38,8),1.112) -(CONVERT(DECIMAL(38,8),.00043499)*((Col1 + Col2 + Col3))) +(CONVERT(DECIMAL(38,8),.00000055) * ((Col1 + Col2 + Col3)) * ((Col1 +Col2 + Col3))) - (CONVERT(DECIMAL(38,8),.00028826) * Col4))) - 450)/100If anyone does see a problem with this approach, could you suggestanother alternative?

View 1 Replies View Related

Store Gitar Codes

Jul 23, 2005

HiIs there any way to store gitar codes in sql server table. or want toset specific "COLLATE".ThanksDishan

View 7 Replies View Related

Why Specify The Char Length In Varchar?

Feb 6, 2002

Newbie question:

Why bother specifing the length in varchar()?
Why not just specify the max and not worry about truncation?

Thanks,

Martin

View 2 Replies View Related

Getting MAX From Char Numbers

Jul 28, 2001

I have a table which will recieve and interface file to be loaded. All the fields are there except an account_id field which is a char(12), but the data is a number 000000000001, 000000000002, etc. These numbers are to be incremented by one. I understand how to write the process using a cursor to run through all the records and to increment them before loading. My question is the best way to get the max number in the existing table which is the char(12) , and icrement the number by one, but retain the leading zeroes I will need. Anyone had the pleasure of doing this providing input greatly appreciated.

View 5 Replies View Related

Need An Unlimited Length Char Field

Dec 7, 1998

Hi,

If I want to make a field of characters to be unlimited length(or maybe 2k for example), what datatype should I use?
Char, varchar and text have a max. limit of 255...

Will appreciate any suggestions.

Thanks,
Nishi

View 4 Replies View Related

Can Varchar Length Be Set To More Than 8000 Char?

May 22, 2006

Hi, everyone, I want to know is there a way for me to set varchar to store more than 8000 characters? (I did checked from sql server books online and i know that the maximum storage for varchar, but i just want to know is there any exceptional way for me to store more than that).

Thanks for any reply.

aex

View 4 Replies View Related

Int Vs. Char For Datatype On Numeric Label?

Jul 12, 2007

I'm designing a database that will not be that large (I would be surprised if it ever surpassed 50,000 rows across all tables), but will be accessed quite often, so I am doing my best to optimize its structure, such as doing 3NF, selecting appropriate data types, etc.

I have a few columns that will contain numeric data (such as an invoice number (from an external source) or location ID). However, one of my classes in college was about database design, and we were taught that if you won't be doing mathmatic computation on a field (such as the invoice or location fields I mentioned earlier), then you should use a string literal type (char, varchar, etc.)

Unfortunatly, the professor did not explain much as to why this should be done. From the standpoint of semantic analysis, these types of fields are probably more labels than they are numbers. However, I don't find that very convincing (or even helpful).

In short, my question is that given a column holding numeric data that isn't worked on in a mathematical sense, is it really better to mark it as a string literal than a number? Any articles or studies I can read relating to this?

I would think that comparisons would be faster with int, as well as data storage (though, as mentioned, that's not as big of a concern). Sadly, Google doesn't have many helpful resources. (Lots of stuff on char vs varchar, though.)

View 12 Replies View Related

Datatype Convert Char To Numeric

Dec 31, 2003

Hi,

I read the topic from JROdden and this case is similiar but...

I got several varchar fields with
values like
1.2
1.3
... these I can covert with
select CONVERT(dec(5,2), fieldname) as fieldname

In fact I also solved undefined- and NULL-values with.
CONVERT(decimal(12, 2), CASE WHEN GESCHKOSTMAX IS NULL OR
GESCHKOSTMAX < '0' THEN '0' ELSE GESCHKOSTMAX END) as GESCHKOSTMAX,

But now there are values like
1,4 and these ones neither CONVERT nor CAST will handle.

I tried the
SELECT DISTINCT KMPAUSCHALE
FROM extr_INTFIRMA
WHERE (isnumeric(KMPAUSCHALE) = 1)

and get
0,40
0.25
0.30 and so on...

The error is:
[Microsoft][ODBC SQL Driver][SQL Server]Error converting datatype varchar to decimal. (or float or numeric (whatever I tried))

I think the easiest way would be to insist on higher data quality but
I also would like to solve this interesting challenge.


Thanks for any hints

By the way, I followed rudys link to
http://rudy.ca/afdb.html
and now I know how I could protect myself !!!!

There must be a voice in my head saying:
Try the db-forum, try it and stay happy... ;-)

best regards and have fun with new year eve.

Michael

View 8 Replies View Related

T-SQL (SS2K8) :: Convert Numeric Value To CHAR(7)

Sep 22, 2014

I have to store the result of a calculation in a column of type CHAR(7) (and am unable to change the column type).

The calculation can have results ranging in size from 0.1234567 to 99999999.

In the first case, I would need to store the value of 0.12345 in the column. In the later case, an error should be thrown.

So I need to store all of the significant digits from the left of the decimal (if there are < 7) and as many of the digits to the right as will fit into a CHAR(7), with the remaining precision being truncated.

View 6 Replies View Related

How To Convert From CHAR To Numeric In The Table

Sep 29, 2005

I have imported some data to sql2k from my old system. Somehow, it importedinvoice amount to char type.I just created another column called invamt2 type NUMERIC so I can copy orconvert content of invamt which is type CHAR. There are about 50,000records.How can I convert/cast from char type to numeric type ?Thanks

View 2 Replies View Related

Help Needed To Convert Char To Numeric

Feb 5, 2008



Hi ,

I am trying to convert a char field of lenght 5 into numeric (5,2) 999.99 format ,
i am getting an arithmentic overflow error.

The Character Data is 5 in length

It works fine if the Data is 00000
it fails if there is any number in the data

Like 10000
or 05000

How do i represent these into Numeric (5,2)

please let me know what taransformation to use and how.

Thanks,

View 2 Replies View Related

Changing Char Length In Stored Procedures

Aug 11, 2004

Hello all, I'm using SQL Server 2000 and have about 250 stored procedures that use an EMPLID parameter or variable of type varchar with a length of 4. I need to change the length to 10 instead and would like to do so without having to open every sp for editing. Is there a way to do this through SQL Server 2000? Does anyone have a script to do this? Any help would be appreciated.

View 1 Replies View Related

How To Get The Max Length Of Numeric Field In A DataSet?

Sep 20, 2006

How to get the max length of numeric  field in a DataSet?   
I have a DataSet bound to an Access database. Is it possible to get the maximum length of numeric field of a table in the DataSet? Many fields in the database tables have maximum length values set in ...

View 1 Replies View Related

Data Type Conversion - Numeric To Char

Jul 12, 2000

I would like to know how to translate a numeric value = 3 to a text or char value = 03.

Any input would be appreciated.

Thanks,


Joel

View 1 Replies View Related

Return Numeric Value All As &#043;ve Numbers

May 16, 2008

Hi All,

I have a table Called Elasticity. Including some other fields it has a field called ElastVal of decimal type (2 places). The records for just this field are like this (example);

ElastVal
-450.88
-32.99
1.22
56.77
0.99


In my select I want to return all the fields from the Elasticity table including Elasticity in a way that even the negative numbers will be reterive as positive.

So in the above example the output should be;
ElastVal
450.88
32.99
1.22
56.77
0.99

How Can I do this in my select?

Please help.

Zee

View 2 Replies View Related

Converting Int To Fixed Length Char With Leading Zeroes

May 25, 1999

Hello All,
Can someone tell me how (in SQL) to convert an integer to a fixed length character filled with leading zeros. For example, I have an integer value of '125'. My user wants to see it displayed as '00000125'. How do I get the zeroes to fill in to a char(8) field when the length of the value differs, ie. '1', '125', '3452', etc.

Thanks in advance,
Terry

View 1 Replies View Related

Character To Numeric Conversion Error- Select Statment On Char Column

Sep 18, 2007

Hi guys/ladies I'm still having some trouble formatting a select statement correctly.
I am using a sqldatasource control on an aspx page. It is connecting via odbc string to an Informix database.
Here is my select statement cut down to the most basic elements.
SELECT     commentFROM         informix.ipr_stucomWHERE     (comment > 70)
The column "comment" contains student grades ranging from 0-100 and the letters I, EE, P, F, etc. Therefore the column is of a char type. This is a problem because I cannot run the above statement without hitting an alpha record and getting the following error
"Character to numeric conversion error"
How can I write this statement where it will work in the datasource control and have it only look at numeric values and skip the alpha values?
I have tried case with cast and isnumeric... I don't think that I have the formating correct.
I have also used:
WHERE (NOT (comment = '  I' OR comment = ' EE' OR comment = ' NG' OR comment = ' WP' OR comment = ' WF' OR comment = '  P' OR comment = '  F'))
This works but is very clunky and could possibly break if other letters are input in the future. There has to be a better way.I am sorry for my ignorance and thanks again for your help.

View 2 Replies View Related

Reporting Services :: Compare Numbers (like Software Versions With Different Length And More Than 1 Decimal)?

Jul 7, 2015

I'm trying to change the background color in a field based on its number value being greater than another number value in an adjacent field. The issue I am having is the format, it's like a software version string or IP address (in this case, it is A/V Signature Versions) where the length of the numbers between the decimal places can be different, and that seems to throw off the comparison.

For example (these are actual values I am comparing);

1.201.1054.0 should evaluate as greater than 1.201.2.0 but when compared, evaluates as FALSE.

View 2 Replies View Related

How To Insert Numbers From A Text Box To A Sql Database Table Column’s Type Numeric?

Nov 3, 2004

Hi,

I am getting an error when I try to insert a number typed in a text box control into a Sql database table column’s type numeric(6,2). For example: If I type 35,22 into the text box, or 35, and then I submit the form to insert the data into database, I get the follow error:

System.FormatException: Input string was not in a correct format.
Line 428: CmdInsert.Parameters.Add(New SqlParameter("@Measure", SqlDbType.decimal, "Measure"))

A piece of the SP inside Sql server:

USE market26
GO
ALTER PROC new_offer
@Offer_id bigint, @Measure numeric(6,2) = null, …

What is wrong? Why it doesn’ t accept the number typed in my text box?

Thank you,
Cesar

View 5 Replies View Related

Store Procedures: Pass Array Of Numbers For IN Clause?

May 24, 2006

How does one pass into a Stored Procedure an array of numbers to be used in an IN clause? If I pass "1,2" in a VARCHAR, the stored procedure sees only the first number (1 in this case).
I'm using VB and ADO.NET, but I don't know how to set up the stored procedure for an array. Is there a parsing function to do this?
CREATE PROCEDURE TestInClause( @TeamList VARCHAR)ASSELECT Name FROM Teams WHERE TeamID IN (@TeamList); /* sees only 1st number */GO

View 2 Replies View Related

Want 2 Store Multiple Room Numbers Of A Hotel In A Single Column Using SQL Server2k.

Jan 15, 2004

Hi!
Want 2 store Multiple room numbers of a hotel in a single column using SQL Server2k.

Can anybody tell me how to do it??

Thanx.

View 2 Replies View Related

Formatting Numbers In A Mixed Column (numbers In Some Cells Strings In Other Cells) In Excel As Numbers

Feb 1, 2007

I have a report with a column which contains either a string such as "N/A" or a number such as 12. A user exports the report to Excel. In Excel the numbers are formatted as text.

I already tried to set the value as CDbl which returns error for the cells containing a string.

The requirement is to export the column to Excel with the numbers formatted as numbers and the strings such as "N/A' in the same column as string.

Any suggestions?



View 1 Replies View Related

T-SQL (SS2K8) :: Procedure Parameter Length Declaration Less Than Column Length?

Jun 30, 2014

is there any way or a tool to identify if in procedure the Parameter length was declarated less than table Column length ..

I have a table

CREATE TABLE TEST001 (KeyName Varchar(100) ) a procedure
CREATE PROCEDURE SpFindNames ( @KeyName VARCHAR(40) )
AS
BEGIN
SELECT KeyName FROM TEST001
WHERE KeyName = @KeyName
END
KeyName = @KeyName

Here table Column with 100 char length "KeyName" was compared with SP parameter "@KeyName" with length 40 char ..

IS there any way to find out all such usage on the ALL Procedures in the Database ?

View 2 Replies View Related

BlobColumn.GetBlobData() With Data Length &&> Integer Length (32767)

Mar 27, 2008

For those of you who would like to reference my exact issue, I'm dealing with the RSExecution SSIS package at the "Update Parameters" data flow task, at the Script Component.

The script tries to split parameter data into name and value. Unfortunately, I have several reports that are passing parameters that are very large. One example has over 65,000 characters all in the normal "&paramname=value&parm2=value..." format.

The code in the script works fine until it gets to one of these very large parameter sets. I have figured out what is causing the issue. Here's some code:

Dim paramBlob as Byte()
paramBlob = Row.BlobColumn.GetBlobData(0, Row.BlobColumn.Length)

The second parameter of the .GetBlobData function takes an INTEGER as its count! Therefore, no matter what kind of datatype I pass to the string that the script will later split, it will be limited to 32767 characters.

THIS IS A PROBLEM!!!

Does anyone know a workaround for this issue? I need all of the parameter data to be reported, and I would hate to have to skip over rows like this. Also, if I'm missing something, please fill me in!

Thanks for your help in advance,
LOSTlover

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved