|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Converting nvarchar to int
Hello all,
I'm trying to convert a nvarchar datatype to int (ie:1234-56-78 to 12345678) . These values are primary keys in two tables. Both these tables have 3500 rows of this key type. I want to convert this to a int so I can make it a AutoNumber primary key so I can increment it. 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 Last edited by ndn_24_7 : October 28th, 2004 at 03:48 PM. Reason: update example |
|
#2
|
|||
|
|||
|
Have u tried first split it and then join it to get rid of the hyphens? Then maybe u'll be able to change it into int or numeric.
|
|
#3
|
|||
|
|||
|
you can do something like: newNumber = clng(replace(RS("KeyNum"), "-", ""))
This will remove the hyphens and convert the string into a number. However, you won't be able to write this (or any) number to an AutoNumber field, since that number is automatically incremented and supplied by the database itself. |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Converting nvarchar to int |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|