Hi All,
I have a database that has a field with phone numbers in.
I want to update the main part of the number to add the area code to
the main number.
I will do a selection on the postcode of the address and then I want to
add the correct area code to the beginning of the number.
Any help please.
Steve
Hi Steve,
First of all:
http://www.aspfaq.com/etiquette.asp?id=5006
Based on this its hard to give some suggestions but assuming some thing
here is some pseudocode
UPDATE CustomerTable
SET phoneNumber = CAST(RegionCode AS VARCHAR(10)) + CAST(phoneNumber
AS VARCHAR(100))
FROM CustomerTable C
INNER JOIN
RegionPhoeTable R
ON C.ZipCode = R.ZipCode
HTH, jens Suessmeyer.
Showing posts with label tothe. Show all posts
Showing posts with label tothe. Show all posts
Monday, March 19, 2012
add to data
Hi All,
I have a database that has a field with phone numbers in.
I want to update the main part of the number to add the area code to
the main number.
I will do a selection on the postcode of the address and then I want to
add the correct area code to the beginning of the number.
Any help please.
SteveHi Steve,
First of all:
http://www.aspfaq.com/etiquette.asp?id=5006
Based on this its hard to give some suggestions but assuming some thing
here is some pseudocode
UPDATE CustomerTable
SET phoneNumber = CAST(RegionCode AS VARCHAR(10)) + CAST(phoneNumber
AS VARCHAR(100))
FROM CustomerTable C
INNER JOIN
RegionPhoeTable R
ON C.ZipCode = R.ZipCode
HTH, jens Suessmeyer.
I have a database that has a field with phone numbers in.
I want to update the main part of the number to add the area code to
the main number.
I will do a selection on the postcode of the address and then I want to
add the correct area code to the beginning of the number.
Any help please.
SteveHi Steve,
First of all:
http://www.aspfaq.com/etiquette.asp?id=5006
Based on this its hard to give some suggestions but assuming some thing
here is some pseudocode
UPDATE CustomerTable
SET phoneNumber = CAST(RegionCode AS VARCHAR(10)) + CAST(phoneNumber
AS VARCHAR(100))
FROM CustomerTable C
INNER JOIN
RegionPhoeTable R
ON C.ZipCode = R.ZipCode
HTH, jens Suessmeyer.
Friday, February 24, 2012
add digits to the front
Hi all,
I have a number like so 778625 and want to make this a more meaningful
date (UK) so how difficult is it to add two digits in this case 19 to
the front of this number?
I have a number like so 778625 and want to make this a more meaningful
date (UK) so how difficult is it to add two digits in this case 19 to
the front of this number?
Many thanks
Sam
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!actually i don't need it to be a date i just need to add 19 to the front
of the number.
Thanks again
Sam
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!|||You can do:
SELECT CAST(CAST(19 AS VARCHAR) + CAST(778625 AS VARCHAR) AS INT)
Another option is to do:
SELECT 19 * POWER(10, LEN(778625)) + 778625
--
- Anith
( Please reply to newsgroups only )|||Not really sure what you mean but something like
select convert(int,'19'+convert(varchar(10),fld))
--
Posted via http://dbforums.com
Monday, February 13, 2012
Add a constant to a select result
Hi,
I have an statement select a, b, c from table with returns the
the contents of the columns a, b, c. I now would like to add a constant to
the result. What does a statement look like to return
content of a, b, c, 1
with 1 is my constant?
Thanks for any advice in advance
Pete
Pete Smith"Pete Smith" <msdn@.nospam.com> wrote in message
news:Oku5O9eUGHA.1672@.tk2msftngp13.phx.gbl...
> Hi,
> I have an statement select a, b, c from table with returns the
> the contents of the columns a, b, c. I now would like to add a constant to
> the result. What does a statement look like to return
> content of a, b, c, 1
> with 1 is my constant?
> Thanks for any advice in advance
> Pete
> --
> Pete Smith
>
SELECT a, b, c, 1 AS d
FROM tbl ;
d is a name for the column containing the constant. Although SQL doesn't
require it, it's always better to give every column a name.
Better still, be explicit about the datatype for your new column. Don't rely
on the server to guess what you intended because it may not always guess
right:
SELECT a, b, c, CAST(1 AS INTEGER) AS d
FROM tbl ;
Hope this helps.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||Hi David,
> SELECT a, b, c, CAST(1 AS INTEGER) AS d
> FROM tbl ;
Thanks, great help. Works excellent!
Thanks again!
Pete
I have an statement select a, b, c from table with returns the
the contents of the columns a, b, c. I now would like to add a constant to
the result. What does a statement look like to return
content of a, b, c, 1
with 1 is my constant?
Thanks for any advice in advance
Pete
Pete Smith"Pete Smith" <msdn@.nospam.com> wrote in message
news:Oku5O9eUGHA.1672@.tk2msftngp13.phx.gbl...
> Hi,
> I have an statement select a, b, c from table with returns the
> the contents of the columns a, b, c. I now would like to add a constant to
> the result. What does a statement look like to return
> content of a, b, c, 1
> with 1 is my constant?
> Thanks for any advice in advance
> Pete
> --
> Pete Smith
>
SELECT a, b, c, 1 AS d
FROM tbl ;
d is a name for the column containing the constant. Although SQL doesn't
require it, it's always better to give every column a name.
Better still, be explicit about the datatype for your new column. Don't rely
on the server to guess what you intended because it may not always guess
right:
SELECT a, b, c, CAST(1 AS INTEGER) AS d
FROM tbl ;
Hope this helps.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||Hi David,
> SELECT a, b, c, CAST(1 AS INTEGER) AS d
> FROM tbl ;
Thanks, great help. Works excellent!
Thanks again!
Pete
Subscribe to:
Posts (Atom)