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.
| Author |
Topic |
|
ndn_24_7
Starting Member
23 Posts |
Posted - 2004-10-28 : 15:26:05
|
| Hello all,I'm trying to convert a nvarchar datatype to int (ie:1234-56-789 to 12345678)These values are primary keys in two tables. Both these tables have 3500 rows of nvarchar primary keys. I want to convert this to a int so I can make it a AutoNumber set to increment. Is this possible? If so, how do I do it. Do I need to delete the dashes first some how? I fairly new to database adminstration, so any guidance will be greatly appreciated. Thank You |
|
|
surefooted
Posting Yak Master
188 Posts |
Posted - 2004-10-28 : 15:47:15
|
You can use the replace function and then convert that to an int. But be warned doing this:SELECT convert(int,REPLACE('000-00-000','-',''))Converts to 0. If you need to keep 8 places, you will need to keep it as a string.-JonShould still be a "Starting Member" . |
 |
|
|
ndn_24_7
Starting Member
23 Posts |
Posted - 2004-10-28 : 17:23:48
|
| I posted an updated topic. |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-10-28 : 21:45:06
|
like what Jon said, replace the dash then change the datatype and read his warning. --------------------keeping it simple... |
 |
|
|
|
|
|