SQL Alter statement
April 6, 2011 6:56 AM Subscribe
SQL SERVER: Need help creating new column in a table with unformatted SSN.
Some of the SSN's in a database are written with dashes, XXX-XX-XXXX. In other tables the SSN's are just XXXXXXXXX.
I'd like to create a new column in the tables where the SSN is formatted with dashes that replaces the the - with nothing, so that it is formatted as XXXXXXXXX.
Any help with this statement, i thought it was:
ALTER TABLE tablename
ADD columnName AS REPLACE(SSN,"-","")
Let me know what you think
posted by fozzie33 to computers & internet (6 answers total)
I'd use:
ALTER TABLE `tablename` ADD `columnName` VARCHAR (100) or whatever...;
UPDATE `tablename` SET `columnName` = REPLACE(SSN,"-","");
posted by le morte de bea arthur at 7:04 AM on April 6, 2011