Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Script to populate field and change format

Author  Topic 

robert693
Starting Member

42 Posts

Posted - 2009-07-06 : 10:27:42
Hello,

I want to run a script to update a table. The table is called External and it has for fields: First_Name, Last_Name, Address, City, State, Zip, Phone, Fax, Email. The email field is not being used so we are going to use it for a faxing system. I want to change the email field to have the first name, last name, suffix, and fax number. The fax number has to be numbers only. For example, (309) 555-5555 should be 3095555555 in the email field. I have this so far, UPDATE [External] SET [External].Email = "RFAX:" & External!First_Name & " " & External!Last_Name & ", " & External!Suffix & "@/FN=" & External!Fax;

I created this in Access first to see if it will work. I would like to know how to change the format of the fax number. If anybody can steer me in the right direction I would appreciate it!

rohitkumar
Constraint Violating Yak Guru

472 Posts

Posted - 2009-07-06 : 10:42:52
use nested
REPLACE(Fax, '(', '')
etc...
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-07-06 : 10:46:14
quote:
Originally posted by robert693

Hello,

I want to run a script to update a table. The table is called External and it has for fields: First_Name, Last_Name, Address, City, State, Zip, Phone, Fax, Email. The email field is not being used so we are going to use it for a faxing system. I want to change the email field to have the first name, last name, suffix, and fax number. The fax number has to be numbers only. For example, (309) 555-5555 should be 3095555555 in the email field. I have this so far, UPDATE [External] SET [External].Email = "RFAX:" & External!First_Name & " " & External!Last_Name & ", " & External!Suffix & "@/FN=" & External!Fax;

I created this in Access first to see if it will work. I would like to know how to change the format of the fax number. If anybody can steer me in the right direction I would appreciate it!




UPDATE [External]
SET EMail = ('RFAX: ' + First_Name + ', ' + Last_Name + ', ' + Suffix + '@/FN=' + Replace(Replace(Replace(Fax,'(',''),')',''),'-',
''))
Go to Top of Page

rohitkumar
Constraint Violating Yak Guru

472 Posts

Posted - 2009-07-06 : 10:58:18
but I would rather leave email as it is and have this string ("RFAX:..." etc) created in my select statement.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2009-07-06 : 12:59:10
However it doesn't look like they are using sql, rather VB



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -